【发布时间】:2016-11-01 18:16:29
【问题描述】:
我有一个高度为Height="500" 的User Control,它将有一个带有一些项目的 TabControl,我想将 320 分配为 height of TabControl,但是我正在使用其他用户控件作为 TabControl 的内容,这些控件的高度分配为 DesignHeight="320"
<UserControl x:Class="GUI.ProcessManager"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:GUI"
mc:Ignorable="d" Width="705" Height="500">
<Grid>
<TabControl Margin="0">
<TabItem Header="Tab 1">
<local:otherUserControl />
</TabItem>
<TabItem Header="Tab 2">
<local:otherUserControl2 />
</TabItem>
</TabControl>
<telerik:RadButton Content="Ok" Height="22" HorizontalAlignment="Left" Margin="25,450,0,0" Name="BtnOk" VerticalAlignment="Top" Width="135" Click="BtnOk_Click" />
<telerik:RadButton Content="Cancel" Height="22" HorizontalAlignment="Left" Margin="545,450,0,0" Name="BtnCancel" VerticalAlignment="Top" Width="90" Click="BtnCancel_Click"/>
</Grid >
</UserControl>
我想给 TabControl 的大小设置为 320,然后我想放置 Ok 和 Cancel 按钮,这样当用户选择选项卡时它们不会改变位置
为此,我添加了一个网格行定义
<Grid.RowDefinitions>
<RowDefinition Height="320"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
并将第 0 行分配给 TabControl:
<TabControl Grid.Row="0" Margin="0">
...
</TabControl>
然后将第 1 行分配给按钮:
<telerik:RadButton Grid.Row="1" Content="Ok" Height="22" HorizontalAlignment="Left" Margin="25,450,0,0" Name="BtnOk" VerticalAlignment="Top" Width="135" Click="BtnOk_Click" />
但我只得到带有选项卡的窗口,然后是一个空白区域但没有按钮正在消失,为什么会发生这种情况或我错过了什么
如何固定 TabControl 的大小,以便在固定大小之后放置按钮?
【问题讨论】:
-
哦!我以为我放了“c#”让我编辑它