开发者

WPF Bind TextBlock to Window's Title

开发者 https://www.devze.com 2023-01-04 02:20 出处:网络
I have a TextBlock on my main window. I would like to bind it\'s text to the window\'s title .. eg: myWindow.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开发者_如何学Python, and I have Googled to death, any help is appreciated.

Thanks.


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

<TextBlock Text="{Binding Title,RelativeSource={RelativeSource FindAncestor,AncestorType=Window}}"  />
0

精彩评论

暂无评论...
验证码 换一张
取 消