I'm sure this is probably something basic in WPF, but I'm new to XAML syntax, I'm trying to wrap my head around it.
Customization
I have a LogItem type - only POCO:
public class LogItem { public string Message {get;set;} public Color MessageColor {get;set;} }
and the LogItem list in my ViewModel:
private ObservableCollection<LogItem> _logItems; public ObservableCollection<LogItem> LogItems { get { return _logItems; } set { if (value != _logItems) { _logItems = value; OnPropertyChanged("LogItems"); } } }
My view model is view-bound, so I can do the following:
<ListBox Grid.Row="0" Margin="0,10,0,0" Grid.ColumnSpan="3" Height="150" ItemsSource="{Binding LogItems}">
(Obviously, I still need to set the text display binding, etc.)
Question
Given that I have the Message and MessageColor in LogItems, what is the correct XAML syntax to associate the text color of an element with the specified color?
c # wpf mvvm xaml listbox
Seankilleen
source share