31

How do I programmatically change the Title in a wpf window?

<Window x:Class="Temp.MainWindow"
 ...
 Title="Contacts">

Change the Title from "Contacts" to "Something new" when the program finds new information as it starts.

1
  • You should use binding. Bind the title property of window to a property of your DataContext. Feb 10, 2015 at 16:47

2 Answers 2

61

To change it you can simply alter the Title property from your code:

this.Title = "Something new";
0
30

Bind it to a property

Title="{Binding WindowTitle}"
2
  • Which one of these two answers is the preferred way? My guess is that binding to a property is the best way. Oct 26, 2016 at 16:54
  • 7
    If you are using an MVVM (or similar) approach then binding would be preferred.
    – Tim Rutter
    Oct 27, 2016 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.