且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置在WPF区窗口的用户控件?

更新时间:2023-12-06 13:21:04

在我与RibbonWindow一点经验,我看到丝带是ribbonwindow本身的内容的一部分。所以,解决办法是公开为设置你的用户控件,这样的功能区窗口的公共方法:

In my little experience with RibbonWindow, i saw that ribbon is part of the content of the ribbonwindow itself. So, a solution could be to expose a public method for the ribbon window that set your usercontrol, like this:

<ribbon:RibbonWindow ...>
<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <ribbon:Ribbon x:Name="Ribbon" />
    //add a container for your usercontrol
    <Grid Name="contentPlaceHolder" Grid.Row="1"></Grid>   
 </Grid>



和代码,你可以设置像

public void SetControl(UserControl uc)
{
   this.contentPlaceHolder.Content = uc; 
}