0

我正在尝试使用 Teleriks RadTransitionControl 仅将数据网格(屏幕的一部分)转换为用户控件视图,我知道我可以使用两个用户控件进行转换,但是否可以将硬编码的 xaml 转换为用户控件?

例如:

     <telerik:RadTransitionControl Grid.Row="1" Grid.RowSpan="2" Content="{Binding UserControl1}">
           <Grid>
              <Datagrid ItemsSource={Binding MyCollection></DataGrid>
              <Button content="Go to usercontrol" Command="{Binding TransitionToUserControl1}" />
           </Grid>
     </telerik:RadTransitionControl>

换句话说,当我选择“转到用户控件”按钮时,我想将内容更改为 UserControl1。我的问题是我不能两次设置内容。出于逻辑原因,我不能将数据网格和按钮分离到另一个用户控件中,它必须与转换控件所在的同一视图分开。关于如何做到这一点的任何建议?

4

1 回答 1

0

所以,试试这个。在 xaml - UserControls 中创建视图。在代码隐藏中创建一个属性:

public UserControl MyActualView {get;set;}

您还应该考虑从按钮处理事件:

private void ButtonClick(object sender, EventArgs e)
{
    MyActualView = new MyUserControl1();
}

我还建议您使用 MVVM 模式,因为您不必处理 PropertyChanged 事件来实现视图。有关 MVVM 的更多信息,请访问 http://www.geekchamp.com/news/understanding-mvvm-a-series-of-mvvm-light-toolkit-tutorials

于 2013-07-08T17:42:13.477 回答