如何将多个面板放入一个选项卡项中?
How to place multiple panels into a tab item?
我在我的设计中添加了一个选项卡控件和一个选项卡项,并希望将 3 个停靠面板水平放置到该选项卡项中。但是我得到一个错误:
The property 'Content' is set more than once.
我想要如下的设计。
TabItem1
个人信息区域-----位置信息-----教育信息
姓名:TextBox1 ----------------城市:TextBox3 ------------学校:TextBox5
姓氏:Textbox2-------------国家:TextBox4
我该如何设计?
<TabControl>
<TabItem Header="Ana Bilgiler">
<DockPanel x:Name="dpMainInformations" LastChildFill="False" Width="230">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,5,5,5">
<TextBlock Text="Müşteri Bilgileri" FontWeight="Bold" HorizontalAlignment="Stretch" Width="200"></TextBlock>
</StackPanel>
<StackPanel x:Name="CustName" Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,5,5,5">
<TextBlock Name="lblCustName" Text="Müşteri adı" Width="100"/>
<TextBox x:Name="txtMusteriAdi" Width="100" Text="{Binding CustName}" IsReadOnly="{Binding IsControlsEditable}"/>
<Button x:Name="btnSelectCust" Content="Seç" Click="Button_Click_5" IsEnabled="{Binding IsControlsEditable}"/>
</StackPanel>
</DockPanel>
<DockPanel LastChildFill="False" Margin="20,5,12,5">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,5,0,5">
<TextBlock Text="Uygunsuzluk Bilgileri" FontWeight="Bold"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,0,0,5">
<TextBlock Name="lblProblemDesc" Text="Tanımı" Width="60"/>
<TextBox MinWidth="150" MaxLength="500" Text="{Binding Definition}" UndoLimit="500" VerticalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True" MinLines="4" MaxWidth="200" Margin="0,0,0,0" IsReadOnly="{Binding IsControlsEditable}" Height="40" Width="300"/>
</StackPanel>
</DockPanel>
</TabItem>
<TabItem Header="Kapanma Bilgileri">
</TabItem>
</TabControl>
您需要将 DockPanel
放在容器面板中,因为 TabItem
只能有一个子元素,如错误消息所述。
例如如果你希望你的 3 个停靠面板大小相同,你可以使用 UniformGrid
:
<TabItem>
<UniformGrid Columns="3">
<DockPanel>
...
<DockPanel/>
<DockPanel>
...
<DockPanel/>
<DockPanel>
...
<DockPanel/>
</UniformGrid>
</TabItem>
我在我的设计中添加了一个选项卡控件和一个选项卡项,并希望将 3 个停靠面板水平放置到该选项卡项中。但是我得到一个错误:
The property 'Content' is set more than once.
我想要如下的设计。
TabItem1
个人信息区域-----位置信息-----教育信息
姓名:TextBox1 ----------------城市:TextBox3 ------------学校:TextBox5
姓氏:Textbox2-------------国家:TextBox4
我该如何设计?
<TabControl>
<TabItem Header="Ana Bilgiler">
<DockPanel x:Name="dpMainInformations" LastChildFill="False" Width="230">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,5,5,5">
<TextBlock Text="Müşteri Bilgileri" FontWeight="Bold" HorizontalAlignment="Stretch" Width="200"></TextBlock>
</StackPanel>
<StackPanel x:Name="CustName" Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,5,5,5">
<TextBlock Name="lblCustName" Text="Müşteri adı" Width="100"/>
<TextBox x:Name="txtMusteriAdi" Width="100" Text="{Binding CustName}" IsReadOnly="{Binding IsControlsEditable}"/>
<Button x:Name="btnSelectCust" Content="Seç" Click="Button_Click_5" IsEnabled="{Binding IsControlsEditable}"/>
</StackPanel>
</DockPanel>
<DockPanel LastChildFill="False" Margin="20,5,12,5">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,5,0,5">
<TextBlock Text="Uygunsuzluk Bilgileri" FontWeight="Bold"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,0,0,5">
<TextBlock Name="lblProblemDesc" Text="Tanımı" Width="60"/>
<TextBox MinWidth="150" MaxLength="500" Text="{Binding Definition}" UndoLimit="500" VerticalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True" MinLines="4" MaxWidth="200" Margin="0,0,0,0" IsReadOnly="{Binding IsControlsEditable}" Height="40" Width="300"/>
</StackPanel>
</DockPanel>
</TabItem>
<TabItem Header="Kapanma Bilgileri">
</TabItem>
</TabControl>
您需要将 DockPanel
放在容器面板中,因为 TabItem
只能有一个子元素,如错误消息所述。
例如如果你希望你的 3 个停靠面板大小相同,你可以使用 UniformGrid
:
<TabItem>
<UniformGrid Columns="3">
<DockPanel>
...
<DockPanel/>
<DockPanel>
...
<DockPanel/>
<DockPanel>
...
<DockPanel/>
</UniformGrid>
</TabItem>