简体   繁体   中英

XAML how to call GUI

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM