题
在630x400窗口,我载有XAML要素:
- 菜单在顶部
- 动态的用户控制
- 脚底部
问题是,当我背景的用户控件, 颜色仅仅下降,尽的内容.我想背景的用户控件涵盖整个用户控件的课程。我已经试过:
- VerticalContentAlignment="拉"的 用户控件
- 方式(="拉"的 用户控件
- VerticalContentAlignment="拉"的 主视图
- 方式(="拉"的 主视图
但色彩仍然拒绝下去。我不想设定一个固定的宽度由于用户能够增加的大小应用程序。
我如何可以获得背景色的我用户控件,以填补该区域全面的用户控件 而不是只有该区域的其内容?
PageItemOptionsView.键
<UserControl x:Class="TestMenu234.Views.PageItemOptionsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
VerticalContentAlignment="Stretch"
VerticalAlignment="Stretch"
Background="#ddd">
<StackPanel Margin="10">
<TextBlock Text="This is the options area."/>
<Button Content="Click to go to the Manage Customers page."
Width="200"/>
</StackPanel>
</UserControl>
主视图.键
<Window x:Class="TestMenu234.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:TestMenu234.Commands"
xmlns:vm="clr-namespace:TestMenu234.ViewModels"
xmlns:v="clr-namespace:TestMenu234.Views"
Title="Main Window" Height="400" Width="630" MinWidth="630">
...
<DockPanel LastChildFill="False">
<Menu DockPanel.Dock="Top">
<MenuItem
Header="Pages" ItemsSource="{Binding AllPageItemViewModels}"
ItemTemplate="{StaticResource CodeGenerationMenuTemplate}"/>
</Menu>
<ContentControl
DockPanel.Dock="Top"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
Content="{Binding CurrentPageItemViewModel}"/>
<Border DockPanel.Dock="Bottom" Padding="5 5 5 0" Background="#eee">
<Grid Background="#eee">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="300"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Slider
Grid.Column="0"
HorizontalAlignment="Left"
Value="{Binding CurrentPageItemViewModelIndex}"
Width="300"
Minimum="0"
Maximum="{Binding HighestPageItemIndex}"/>
<TextBlock Grid.Column="1"
HorizontalAlignment="Center" FontWeight="Bold"
Text="{Binding CurrentPageItemViewModelTitle}"/>
<DockPanel Grid.Column="2" Margin="0 0 0 5" LastChildFill="False">
<Button
Margin="3 0 0 0"
DockPanel.Dock="Right"
HorizontalAlignment="Right"
Content="Next" Command="{Binding NextPageCommand}"/>
<Button
DockPanel.Dock="Right"
Content="Prev" Command="{Binding PreviousPageCommand}"/>
</DockPanel>
</Grid>
</Border>
</DockPanel>
</Window>
解决方案
你有没有尝试过...
- 设置保证金="0"
- 让你的控制最后一个孩子的DockPanel与LastChildFill="真实的"
不隶属于 StackOverflow