在我的应用程序中,我有几个UserControl
。一个是显示所有人。因此,我有以下UserControl
,它显示在我的MainWindow的内容部分中:
<UserControl x:Class="ScM.Contents.View.PersonssView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:viewModel="clr-namespace:ScM.Contents.ViewModel"
xmlns:view="clr-namespace:ScM.Contents.View"
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"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
<UserControl.DataContext>
<viewModel:PersonsViewModel />
</UserControl.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<view:PersonsTreeView Grid.Column="0" Margin="2"
OpenPerson="{Binding DataContext.OpenPersonCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"
Persons="{Binding DataContext.Persons, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,
RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" />
<GridSplitter Grid.Column="1" Width="2" ShowsPreview="True" VerticalAlignment="Stretch"
HorizontalAlignment="Center" Margin="0,2" />
<DockPanel LastChildFill="True" Grid.Column="2" Margin="2">
<ContentControl Content="{Binding CurrentContent, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinWidth="400"/>
</DockPanel>
</Grid>
如果用户点击了PersonsTreeView中的TreeViewItem
,则应在UserControl
中显示另一个ContentControl
。
UserControl
中显示的ContentControl
称为PersonView,看起来像
<UserControl x:Class="ScM.Contents.View.PersonView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:viewModel="clr-namespace:ScM.Contents.ViewModel"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.DataContext>
<viewModel:PersonViewModel/>
</UserControl.DataContext>
<TabControl>
<TabItem Header="Personal">
<GroupBox Header="Name">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Firstname:"/>
<TextBox Grid.Row="0" Grid.Column="1"></TextBox>
<Label Grid.Row="1" Grid.Column="0" Content="Lastname:"/>
<TextBox Grid.Row="1" Grid.Column="1"></TextBox>
</Grid>
</GroupBox>
</TabItem>
</TabControl>
我现在的问题是,PersonView中的控件非常小(因此也是AutoSize)。我以为他们会*(最大)。
我做错了什么?