У меня есть класс со следующими свойствами:
Сообщение (строка), Добавлено (DateTime) и LogLevel (строка)
В моем App.xaml у меня есть следующее:
<Application.Resources>
<ImageSource x:Key="Critical">Gfx/Log/Critical.png</ImageSource>
<ImageSource x:Key="Info">Gfx/Log/Information.png</ImageSource>
<ImageSource x:Key="Error">Gfx/Log/Error.png</ImageSource>
<ImageSource x:Key="Warning">Gfx/Log/Warning.png</ImageSource>
</Application.Resources>
LogLevel в вышеприведенном классе может иметь одно из следующих 4 значений ресурса ImageSource, определенных в файле app.xaml.
Я использую WPF Toolkit из codeplex: текст ссылки
<my:DataGrid Grid.Column="0" Grid.Row="1" AutoGenerateColumns="False" Name="userLogGrid">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Added" Binding="{Binding Added}" />
<my:DataGridTextColumn Header="Message" Binding="{Binding Message}" />
<my:DataGridTextColumn Header="Message" Binding="{Binding LogLevel}" />
<my:DataGridTemplateColumn Header="Level">
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{DynamicResource {Binding LogLevel}}" />
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
</my:DataGrid.Columns>
</my:DataGrid>
Итак ... LogLevel привязаны к сетке ... но мое изображение не отображается ... Я понятия не имею, правильно ли это сделать ... или есть лучшие способы ... возможно у меня ошибка в коде ....
Я даже не уверен, как это отладить, так как его xaml, и я только начал его использовать ...
Любая помощь очень ценится ...
Это мой первый пост "Stackoverflow" ... так что если форматирование не идеально ... Я научусь этому ...