У меня есть DataGrid
как:
<DataGrid Grid.Row="4" Name="grvAllCry" Margin="5,5,5,5" ItemsSource="{Binding}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Rank" Width="10*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Rank}" Foreground="#46BF6E"></Label>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Как видите, я установил Foreground
строки DataGrid
, равной "# 46BF6E". Но у меня есть много DataGrid
, и я хочу повторно использовать эти переменные. Что-то вроде:
public static class Config
{
public static string MyGreen = "#46BF6E";
public static string MyRed = "#D14836";
public static string MyBlue = "#428BCA";
}
Есть ли способ, как я могу создать такой класс и использовать его переменную во многих различных файлах xaml? Например:
<Label Content="{Binding Rank}" Foreground="MyGreen"></Label>
Я не знаю, как вызвать переменную из файла .cs в то время как в файле xaml, пожалуйста, помогите мне.