Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Bind TextBlock to Window's Title

I have a TextBlock on my main window. I would like to bind it's text to the window's title .. eg: myWindow.Title.

This has been bugging me all night, and I have Googled to death, any help is appreciated.

Thanks.

like image 759
tcables Avatar asked Jun 18 '10 05:06

tcables


1 Answers

The simplest way is just to bind back to the parent window:

<TextBlock Text="{Binding Title,RelativeSource={RelativeSource FindAncestor,AncestorType=Window}}"  />
like image 93
Matt Hamilton Avatar answered Oct 04 '22 21:10

Matt Hamilton