How to change text color in Label (TextBlock)?

    2 answers 2

    Label .

    To simply set out markup

    <Label Background="Black" Foreground="White" /> 

    To change in the process of markup

     <Label Background="{Binding Background}" Foreground="{Binding Foreground}" /> 

    where, for example, Background

      private string _background; public string Background { get { return _background; } set { _background = value; OnPropertyChanged("Background"); } } 
    • 2
      Background should be done not with a string property, but with a Brush. - AlexeyM

    In the code I change like this

     LabelName.Foreground = Brushes.Black; 
    • And why not through Binding? - VladD
    • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky
    • LabelName.Foreground = Brushes.Black; What is there not clear? Simply in the C # code we insert it - and the text in the label changes its color. I myself was looking for this question - all for some reason they are sent to the markup. - second