Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ListBox WPF:更改SelectedItem的前景色并保留材质设计?_C#_Wpf_Listbox_Material Design_Listboxitem - Fatal编程技术网

C# ListBox WPF:更改SelectedItem的前景色并保留材质设计?

C# ListBox WPF:更改SelectedItem的前景色并保留材质设计?,c#,wpf,listbox,material-design,listboxitem,C#,Wpf,Listbox,Material Design,Listboxitem,如何在不从材质设计中删除样式的情况下更改SelectedItem的圆形颜色 这可以工作,但会从材质设计中删除样式: <ListBox TextElement.Foreground="Black"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel IsItemsHost="True" />

如何在不从材质设计中删除样式的情况下更改SelectedItem的圆形颜色

这可以工作,但会从材质设计中删除样式:

<ListBox TextElement.Foreground="Black">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True" >
                            <Setter Property="FontWeight" Value="Bold" />
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="Foreground" Value="White" />
                        </Trigger>
                    </Style.Triggers>
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                    </Style.Resources>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>

如何添加样式而不是替换它?

将样式更改为BasedOn=“{StaticResource MaterialDesigningListBoxItem}”


将样式更改为BasedOn=“{StaticResource MaterialDesigningListBoxItem}”


 <ListBox.ItemContainerStyle>
       <Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignListBoxItem}">
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True" >
                            <Setter Property="FontWeight" Value="Bold" />
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="Foreground" Value="White" />                               
                        </Trigger>
                    </Style.Triggers>
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                    </Style.Resources>
      </Style>
 </ListBox.ItemContainerStyle>