开发者

XAML how to call GUI

开发者 https://www.devze.com 2022-12-20 23:59 出处:网络
How can I call the UI for an 开发者_开发知识库XAML from another class please? Thanks. :)If the XAML is a Window, instantiate the XAML class and call Show().

How can I call the UI for an 开发者_开发知识库XAML from another class please?

Thanks.

:)


If the XAML is a Window, instantiate the XAML class and call Show().

<Window x:Class="MyWindow"... >
...
</Window>

MyWindow w = new MyWindow();
w.Show();


You can use the x:FieldModifier XAML attribute to make a control public or internal like you would in Windows Forms but this is frowned upon. You should instead either create properties in your code-behind class or you should look into separated presentation patterns such as MVVM which encourage little to no direct manipulation of the UI.

0

精彩评论

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

关注公众号