功能区控件双击功能

时间:2013-10-23 16:44:07

标签: wpf ribbon double-click ribbon-control

我们知道双击功能区控件上的选项卡会打开菜单&保持固定,直到用户再次双击任一选项卡。这基本上调整了功能区下方的行的大小。 有没有办法控制这个调整大小的行为?我想让它从行的上半部分调整大小,但要保持行的底部固定。这样做的目的是将用户控件放置在功能区下方的行中,该行在底部具有工具栏。双击后,工具栏位于第三行&隐藏&仅当用户再次双击功能区时才可见。因此,如果我可以控制调整大小行为以保持行从底部固定,即使用户双击功能区,我也能够查看工具栏。有没有办法实现这个目标? 任何帮助/建议将不胜感激。

编辑:添加样本XAML以便更清楚地理解。 `

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto/>
        <RowDefinition Height="*"/>
        <RowDefinition Height=30/>
    </Grid.RowDefinitions>
    <Ribbon Grid.Row=0/>
    <UserControlWithEmbeddedToolbarHere Grid.Row=1/>
    <!--The toolbar is embedded within the user control & placed at the bottom of the user control-->
    <StatusBarHere Grid.Row=2/>
</Grid>

`

1 个答案:

答案 0 :(得分:1)

你的窗口应该包含RowDefinitions中的MinHeight,它是工具栏的高度:

<Window>
    <Grid>
        <Grid.RowDefinitions>
           <RowDefinition Height="Auto"/>
           <RowDefinition Height="*" MinHeight="40"/>
           <RowDefinition Height="30"/>
        </Grid.RowDefinitions>
        <Ribbon Grid.Row="0">
        </Ribbon>
        <UserControlHere Grid.Row="1">
        </UserControlHere>
        <StatusBar Grid.Row="2">
        </StatusBar>
    </Grid>
</Window>

带工具栏的UserControl:

<UserControl>
    <Grid>
        <Grid.RowDefinitions>
           <RowDefinition Height="*"/>
           <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid>
           Everything else
        </Grid>
        <ToolbarHere Grid.Row="1">
        </ToolbarHere>
    </Grid>
</Window>

在您的用户控件中,通过指定工具栏的高度,您可以“确保”在网格中为其提供空间。高度=“*”是“自动”之后的“其他所有”(这是工具栏需要的空间)。

您的窗口首先为功能区创建空间,然后是状态栏,然后是您的用户控件(因为高度=“*”)。如果您的渲染色带是(我只是说...)40并且您的状态栏是30,如您所提到的那样,您的窗口高度为80,那么您的用户控件将只有高度10(80-40-30),因此您可能不会在用户控件中查看工具栏。

考虑添加一个包含用户控件的scrollviewer,或者为窗口设置最小高度。

相关问题