0
我正在開發一個VSIX(Visual Studio Extension)項目。它包含一個WPF DataGrid。當DataGrid變爲非活動狀態(失去焦點)時,我需要設置自定義DataGrid行高亮顏色,基於Visual Studio Theme的。如何設置基於Visual Studio主題的WPF DataGrid的不活動行顏色
雖然很多類似那種Q &由於通過堆棧溢出發現我無法找到這是基於Visual Studio主題的解決方案。
我遇到了下面這段代碼(風格)。但它不包括我的要求,請幫助解決此問題。
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}, Path=IsKeyboardFocusWithin}" Value="False" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<!--Following Background color has to be changed based on VS theme-->
<Setter Property="Background" Value="DarkGray" />
<Setter Property="Foreground" Value="{DynamicResource VsBrush.WindowText}" />
<!--This BorderBrush color has to be changed based on VS theme-->
<Setter Property="BorderBrush" Value="DarkGray"/>
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
感謝
問題聽到的是基於Rawbackground的VsBrush顏色,我需要申請/設置無效行高亮顏色。 換句話說 If(Vs Theme = Dark)Then Inactive Rowbackground = Red, If(Vs Theme = Light)Then Inactive Rowbackground = Green Thanks –