0

我需要帮助来更改 SurfaceListBox 选择的颜色。

现在我使用这个:

<Style x:Key="styleSurfaceListBox" TargetType="{x:Type my:SurfaceListBox}">
    <Setter Property="ItemsPanel">
       <Setter.Value>
           <ItemsPanelTemplate>
               <StackPanel Orientation="Horizontal"
               VerticalAlignment="Center"
               HorizontalAlignment="Center"
               Background="Transparent" />                        
           </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>            
</Style>

我需要什么使选择颜色透明?

4

1 回答 1

0

感谢 dvvrd!

我创建我的SurfaceListBoxItem风格是这样的:

     <Style x:Key="item" TargetType="{x:Type my:SurfaceListBoxItem}"  >
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Foreground" Value="Transparent" />
                <Setter Property="Background" Value="Transparent" />
            </Trigger>
            <Trigger Property="IsFocused" Value="true">
                <Setter Property="Foreground" Value="Transparent" />
                <Setter Property="Background" Value="Transparent" />
            </Trigger>

            <Trigger Property="IsEnabled" Value="true">
                <Setter Property="Foreground" Value="Transparent" />
                <Setter Property="Background" Value="Transparent" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Foreground" Value="Transparent" />
                <Setter Property="Background" Value="Transparent" />
            </Trigger>                
        </Style.Triggers>
    </Style>

然后我指出ItemContainerStyle

SurfaceListBox1.ItemContainerStyle = (Style)this.Resources["item"]; //item is the KEY on my style.

再次感谢 dvvrd!

于 2012-08-24T11:46:28.937 回答