I want that the picture that comes from the usercontrol will stratch all over the yellow background and not only in that thin line there .
I have stretched every possible thing there but still i have this problem
my main window
<Window x:Class="DBTool.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:View="clr-namespace:DBTool.View"
xmlns:ViewModel="clr-namespace:DBTool.ViewModel"
Title="MainWindow" Height="332" Width="528" >
<Window.Resources>
<!-- These four templates map a ViewModel to a View. -->
<DataTemplate DataType="{x:Type ViewModel:SelectDataBaseViewModel}">
<View:SelectDataBase />
</DataTemplate>
<DataTemplate DataType="{x:Type ViewModel:MySqlPageViewModel}">
<View:MySqlPageView />
</DataTemplate>
</Window.Resources>
<Grid ShowGridLines="True" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ToolBar Grid.Row = "0" Height="26" HorizontalAlignment="Stretch" VerticalAlignment="Top" Name="toolBar1" Width="Auto" DockPanel.Dock="Top" />
<!-- <View:SelectDataBase x:Name="DetailView"/>-->
<Grid VerticalAlignment="Bottom" Grid.Row = "2" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="4" Background="Azure" Margin="10" Command="{Binding Path=MoveNextCommand}" >Next</Button>
<Button Grid.Row="0" Grid.Column="3" Background="Azure" Margin="10" Command="{Binding Path=MovePreviousCommand}">Previous</Button>
</Grid>
<Border Background="Yellow" Grid.Row = "1">
<HeaderedContentControl VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" Content="{Binding Path=CurrentPage}" Header="{Binding Path=CurrentPage.DisplayName}" />
</Border>
</Grid>
the user control
<UserControl x:Class="DBTool.View.SelectDataBase"
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" VerticalConten开发者_运维技巧tAlignment="Stretch"
VerticalAlignment="Stretch" d:DesignHeight="300" d:DesignWidth="300" >
<UserControl.Background >
<ImageBrush Stretch="UniformToFill" ImageSource="..\Resources\DBSelection.jpg" ></ImageBrush >
</UserControl.Background >
<Grid VerticalAlignment="Stretch">
<!--<RadioButton Content="MySQL" Height="16" HorizontalAlignment="Left" Margin="36,112,0,0" Name="radioButton1" VerticalAlignment="Top" />
<RadioButton Content="MsSQL" Height="16" HorizontalAlignment="Left" Margin="36,134,0,0" Name="radioButton2" VerticalAlignment="Top" />-->
<ItemsControl FontWeight="Normal" ItemsSource="{Binding Path=AvailableBeanTypes}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding Path=DisplayName}" IsChecked="{Binding Path=IsSelected}" GroupName="BeanType" Margin="2,3.5"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
will be glad for any help , just cannot solve this out :-(
Since your HeaderedContentControl does not explicitly set the Height it defaults to Auto which is defined by your grid height in the user control. And because that also is not set then it will be set to the size of the ItemsControl, which in this case is only the height of the 2 radio buttons. To fix it you must explicitly set the height of ItemsControl.
My best guess after a quick glance is the RowDefinitions
in the main window:
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
Perhaps try changing the height of all of them to a fixed number, see if that fixes it?
In the ImageBrush give Uniform instead of UnifromToFill
精彩评论