2011-02-17 3 views
0

Je veux que l'image qui vient de l'usercontrol rayonne sur tout le fond jaune et pas seulement dans cette mince ligne.ce qui ne va pas avec l'étirement de mon usercontrol

J'ai tendu toutes les choses possibles là, mais j'ai encore ce problème

ma fenêtre principale

<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>  

le contrôle utilisateur

<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" VerticalContentAlignment="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> 

seront heureux pour toute aide, tout ne peut pas résoudre ceci :-(

My code

Répondre

2

Étant donné que HeaderedContentControl ne définit pas explicitement la hauteur, il est défini par défaut sur Auto, ce qui est défini par la hauteur de votre grille dans le contrôle utilisateur. Et parce que cela n'est pas non plus défini, il sera réglé à la taille de ItemsControl, qui dans ce cas est seulement la hauteur des 2 boutons radio. Pour le réparer, vous devez définir explicitement la hauteur de ItemsControl.

+0

La seule solution qui fonctionne vraiment pour moi –

0

Ma meilleure estimation après un rapide coup d'œil est le RowDefinitions dans la fenêtre principale:

<Grid.RowDefinitions> 
    <RowDefinition Height="Auto"/> 
    <RowDefinition Height="*" /> 
    <RowDefinition Height="Auto"/> 
</Grid.RowDefinitions> 

Peut-être essayer de changer la hauteur de tous à un nombre fixe, voir si cela le fixe?

+0

désolé, mais vous avez tort, parce que la frontière prend l'espace droit, mais que dans la frontière non étirement. –

0

Dans le ImageBrush donnent uniforme au lieu de UnifromToFill

Questions connexes