开发者

WPF element binding across separate windows

I can do element-to-element binding in WPF: For example, I've got a window that has a slider control and a textbox, and the textbox dynamically displays the Value property of the slider as the us开发者_开发问答er moves the slider.

But how do i do this across separate windows (in the same project, same namespace)?

The reason is that my main application window containing the textbox has a menu option that will open an 'options' window containing the slider control.


You should use a (global) ViewModel, containing the data you need to share, and bind to the property from that ViewModel.

This way the changes in either of windows are reflected in the bound data object, and back.


You dont. Point. Databinding has to go to an element accessible in the same control.

What you can do is have the options menu bind go an object that it has in it's own code (property) that gets populated to the same object the othe rwindow uses as data source.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜