简体   繁体   English

wpf如何更改网格内的控件

[英]wpf how to change controls within a grid

I started looking at wpf recently and am having a hard time wrapping my head around it. 我最近开始看wpf,现在很难把头缠在它上面。 I have written plenty of c++ and c# but xmal seems a bit foreign to me right now. 我已经写了很多c ++和c#,但是xmal对我来说似乎有点陌生。 I have created a main window that has a grid. 我创建了一个具有网格的主窗口。 Within the grid i have a user control that i dynamically create buttons. 在网格内,我有一个用户控件,可以动态创建按钮。 Depending on which button the user presses the control should load another user control in place of the current control, kind of how a win7 phone would work... This is a desktop app not a phone app.. just wanted to give you an example of the desired result. 取决于用户按下控件的哪个按钮,应该加载另一个用户控件来代替当前控件,这类似于win7手机的工作方式。这是桌面应用程序,不是手机应用程序。预期结果。 I have looked at Pages and Navigation but i don't think this what i'm looking for. 我看过页面和导航,但是我不认为这是我想要的。 Can someone please point me in the right direction. 有人能指出我正确的方向吗? Thanks 谢谢

You could put a "ContentControl" in your Xaml and than in your code change it's content, like: 您可以在Xaml中放入“ ContentControl”,然后在代码中更改其内容,例如:

ContentControl1.Content = new MyUserControl(); ContentControl1.Content = new MyUserControl();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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