I've run into a rather bizarre thing happening, I have a DataGrid
defined in a WPF XMAL page that has the following declared:
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF3399FF" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="#FF3399FF"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="White" />
</DataGrid.Resources>
Technically the two Inactive
SystemColors
types are from .net 4.5, however I can compile the program when it's set to target .net 4, and these Inactive brushes work, but while it's set to target .net 4 loading the XMAL designer page in Visual Studio throws the error The member "InactiveSelectionHighlightTextBrushKey" is not recognized or is not accessible.
and then blocks the designer view. But it still compiles and displays as defined above in the program.
This seems very inconsistent to say the least and I can’t tell if this is a Visual Studio 2012 issue or if it’s allowing the program to compile because my development computer has .net 4.5 installed and it’s just changing the target framework when it sees that something is using it (I highly doubt this though). Or is it possible that the Inactive types are in .net 4 but not listed as supported in the documentation and just causing this issue in VS?
Is there a better way to do this in .net 4 to allow me to set the inactive selection color of a DataGrid row? Or is the only way to do this being to upgrade to .net 4.5?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…