我是WPF编程新手。我有一个UserControl,它是Ribbon Window中DocumentPanel的内容。 问题是,当我调整窗口大小时,它会剪切控件并且它们不是滚动条。怎么做才能解决这个问题? UserControl中的控件必须与窗口一起调整大小。有什么想法吗?
这是我的标记:
<UserControl xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" x:Class="XproWPF.UserControls.usContactForm"
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"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1024" MinHeight="600" MinWidth="1024">
<Grid x:Name="grdContactMain" ShowGridLines="False">
<Grid.Resources>
<Style TargetType="Border">
<Setter Property="Padding" Value="5"></Setter>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="15*" />
<RowDefinition Height="20*" />
<RowDefinition Height="20*" />
<RowDefinition Height="15*" />
</Grid.RowDefinitions>
<GroupBox Header="Internet " HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="0">
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="15*" />
<RowDefinition Height="15*" />
<RowDefinition Height="15*" />
<RowDefinition Height="15*" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<!--<Button Content="Email1" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100" Click="Button_Click"/>-->
<Button Name="BtnEmail" Content="Email" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100">
</Button>
<Button Click="btnEmailExpand_Click" Name="btnEmailExpand" Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch">
<Button.ContextMenu>
<ContextMenu x:Name="emailContextMenu" />
</Button.ContextMenu>
</Button>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" MinWidth="445">
<TextBox Name="txtEmail1" MinWidth="445" Text="Email" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" />
<TextBox Name="txtEmail2" MinWidth="445" Text="Email2" Visibility="Collapsed" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBox Name="txtEmail3" MinWidth="445" Text="Email3" Visibility="Collapsed" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</StackPanel>
<Label Content="Display as" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<Label Content="Web Page Address" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBox Grid.Column="1" Grid.Row="2" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<Label Content="IM Address" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<TextBox Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</Grid>
</GroupBox>
<GroupBox Header="Phone Numbers " HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch" Grid.Row="2">
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="50*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25*" />
<RowDefinition Height="25*" />
<RowDefinition Height="25*" />
<RowDefinition Height="25*" />
<!--<RowDefinition />-->
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<Button Name="BtnContactBusiness" Content="Business" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100" Click="BtnContactBusiness_Click"/>
<Button Name="BtnContactBusinessExpand" Content=" + " Click="BtnBusinessExpand_Click" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch">
<Button.ContextMenu>
<ContextMenu x:Name="businessContextMenu" />
</Button.ContextMenu>
</Button>
</StackPanel>
<TextBox Text="busniess text" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal">
<Button Content="Home" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Text="Home text" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal">
<Button Content="Fax" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Grid.Column="1" Grid.Row="2" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="3" Orientation="Horizontal">
<Button Content="Mobile" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</Grid>
</GroupBox>
<GroupBox Header="Addresses" HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch" Grid.Row="3" >
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="35*" />
<ColumnDefinition Width="15*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="34*" />
<RowDefinition Height="33*" />
<RowDefinition Height="33*" />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<Button Name="BtnContactAddressHome" Content="Home" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100" Click="BtnContactAddressHome_Click"/>
<Button Content=" + " Click="BtnHomeExpand_Click" Name="BtnHomeExpand" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch">
<Button.ContextMenu>
<ContextMenu x:Name="homeContextMenu" />
</Button.ContextMenu>
</Button>
</StackPanel>
<TextBox Grid.Column="1" Grid.RowSpan="2" TextWrapping="Wrap" AcceptsReturn="True" Grid.Row="0" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal">
<Button Content="Work" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal">
<Button Content="Mailing" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<Image Grid.Column="2" Grid.RowSpan="2" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Source="/XtremeProcurementWPF;component/Images/description_img.png" />
</Grid>
</GroupBox>
<GroupBox Header="Social Media" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch">
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!--<RowDefinition Height="20*" />-->
<RowDefinition Height="25*" />
<RowDefinition Height="25*" />
<RowDefinition Height="25*" />
<RowDefinition Height="25*" />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<Button Content="Website" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100" />
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Text="website text" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal">
<Button Content="Facebook" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Grid.Column="1" Grid.Row="1" Text="facebook text" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal">
<Button Content="Linkedin" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Grid.Column="1" Grid.Row="2" Text="linked text" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="0" Grid.Row="3" Orientation="Horizontal">
<Button Content="Twitter" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Width="100"/>
<Button Content=" + " HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</StackPanel>
<TextBox Grid.Column="1" Grid.Row="3" Text="Twitter text" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
</Grid>
</GroupBox>
<Image Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch" Source="/XproWPF;component/Images/business-card2.jpg"/>
<GroupBox HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" >
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="30*" />
<ColumnDefinition Width="30*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20*" />
<RowDefinition Height="20*" />
<RowDefinition Height="20*" />
<RowDefinition />
<!--<RowDefinition Height="16*" />-->
<!--<RowDefinition Height="16*" />-->
</Grid.RowDefinitions>
<Button Name="BtnContactFullname" Content="Full Name" Grid.Column="0" Grid.Row="1" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="BtnContactFullname_Click"/>
<TextBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch"/>
<dxe:ComboBoxEdit IsTextEditable="False" Grid.Column="1" Grid.Row="2" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<Label Content="Gender" Grid.Row="2" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" />
<Image Grid.Column="2" Grid.Row="2" Grid.RowSpan="2" HorizontalAlignment="Stretch" Margin="2" VerticalAlignment="Stretch" Source="/XproWPF;component/Images/description_img.png" />
</Grid>
</GroupBox>
</Grid>
</UserControl>