开发者

Silverlight programmatic databind to Page Title Property not updating

开发者 https://www.devze.com 2022-12-22 09:53 出处:网络
I\'m using the Title property of a Page to set a textblock in the mainwindow. Programmatic databinding is working for one time. But when i change the titl开发者_运维技巧e property on a page the Brows

I'm using the Title property of a Page to set a textblock in the mainwindow.

Programmatic databinding is working for one time. But when i change the titl开发者_运维技巧e property on a page the Browser title & tab are updated, but my textblock not.

In the NavigatedTo method in mainview:

Page page = ((Page)e.Content);

Binding binding = new Binding();
binding.Path = new PropertyPath("Title");
binding.Source = page;
binding.Mode = BindingMode.OneWay;

Header.SetBinding(TextBlock.TextProperty, binding);


Title is not implemented as a dependency property hence bindings are not informed of changes made to it.

Ultimately you will need to co-operation of the code that changes the Title property.

Perhaps the simplest approach would be to create a ChangeTitle method on the Page and have that update both the Title property and the "Header" element.

0

精彩评论

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