KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I would like to bind the foreground property of a TextBlock to a Property in my ViewModel. This doesn't work : Edit View : TextBlock Text="{Binding Path=FullName, Mode=OneWay}" Foreground="{Binding Path=ForegroundColor}" Margin="0 5 3 5" Code behind: CustomerHeaderViewModel customerHeaderViewModel = new CustomerHeaderViewModel(); customerHeaderViewModel.LoadCustomers(); CustomerHeaderView.DataContext = customerHeaderViewModel; View Model: private System.Windows.Media.Brush _foregroundColor; _foregroundColor = System.Windows.Media.Brushes.DarkSeaGreen; public System.Windows.Media.Brush ForegroundColor { get { return _foregroundColor; } set { _foregroundColor = value; OnPropertyChanged("ForegroundColor"); } } public CustomerHeaderViewModel() { ForegroundColor = System.Windows.Media.Brushes.Red; } All other properties (Text etc) correctly bind. What am I doing wrong?
Tags (comma-separated)
Save Edits
Cancel