I have a textblock that is a 'status label'. I want this label to be updated, and when that happens, I want its color to be also set automatically - as well as visibility (Label invisible until it has content).
The problem is, that if I specify anything more than the text binding, then the textblock does not change (i.e. text does not appear, and it is still hidden). Actually, I tried also without binding visibility, and it appears that the Foreground also blocks the binding.
<TextBlock x:Name="StatusInfo"
                               HorizontalAlignment="Center" VerticalAlignment="Bottom"
                               FontSize="9"
                               Visibility="{Binding ElementName=ThisUc,
                                                    Path=StatusLabelVisibility}"
                               Text="{Binding ElementName=ThisUc,
                                              Path=StatusLabel}"
                               Foreground="{Binding ElementName=ThisUc,
                                                    Path=StatusLabelBrush}" />
This is all in a UserControl, so I am using dependency properties for StatusLabel property, as I want to bind it to properties in main window... Foreground and Visibility properties are not dependency properties, as I don't want to expose them. This is my property setter and getter:
public string StatusLabel
        {
            get { return (string)GetValue(StatusLabelProperty); }
            set
            {
                SetValue(StatusLabelProperty, value);
                RaisePropertyChanged("StatusLabel");
                if (value != string.Empty)
                {
                    StatusLabelVisibility = System.Windows.Visibility.Visible;
                    if (value.HasAny("success", "ok") && !value.HasAny("partial"))
                    {
                        StatusLabelBrush = Brushes.Green;
                    }
                    else if (value.HasAny("fail"))
                    {
                        StatusLabelBrush = Brushes.DarkRed;
                    }
                    else if (value.HasAny("partial"))
                    {
                        StatusLabelBrush = Brushes.DarkGoldenrod;
                    }
                    else
                    {
                        StatusLabelBrush = Brushes.Black;
                    }
                }
                else
                {
                    StatusLabelVisibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
Please let me know what am I doing wrong, perhaps that's not the way to go altogether?
Cheers
====================
While Meredith's answer solved the issue, let me just post a comment for future reference (as it was not obvious for me):
Here it goes - if you assign the UserControl property directly, not via property binding, it appears to lose the 'bound' - and if you try to change the bound property again, it won't update the control as it would have before it 'lost the bound'
Cheers