Search code examples
c#wpfforegroundcontentpresenter

WPF C# Set "ContentPresenter.Foreground" by code


I could only find xaml specifiy solutions to this problem using TextElement.Foreground="...".
But I'd like to set the Foreground of a ContentPresenter in C#.
Can you tell me how that works?

Thank you very much!


Solution

  • Attached properties is what you are looking for. You can check msdn

    In general, you'll want to do something like myContentPresenter.SetValue(ForegroundProperty, myForeground)