开发者

make user control stretch to all given space

I have some user control that I am putting in a window control , i dont want to have a fixed size in the user control i want it to catch all the space were i put it . What should i add to my code ?

   <UserControl x:Class="DBTool.View.SelectDataBase"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            >


    <UserControl.Background >
        <ImageBrush ImageSource="..\Resources\DBSelection.jpg" ></ImageBrush >
    </UserControl.Background >

    <Grid>
     <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>
</UserControl>

My window code

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

            <DockPanel LastChildFill="True" >


        <ToolBar Height="26" HorizontalAlignment="Stretch" VerticalAlignment="Top" Name="toolBar1"  Width="Auto" DockPanel.Dock="Top"  />

        <Grid  VerticalAlignment="Bottom" DockPanel.Dock="Bottom"  >
            <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>

            <TextBox Name="txtInput" Grid.Column="1"/>
            <Label Content="{Binding Text, ElementName=txtInput, 
                     UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" />


        </Grid>
       <!-- <View:SelectDataBase x:Name="DetailView"/>-->
        <Border Background="White" Grid.Column="1" Grid.Row="0">
            <HeaderedContentControl 
        Content="{Binding Path=CurrentPage}" 
        Header="{Binding Path=CurrentPage.DisplayName}" 
        />
        </Border>
    </DockPanel>


</Window>

make user control stretch to all given space

But i want to see the image take the whole white space there .


you need to learn about panels (grid, stack etc) and their properties. The height and width properties and if i remember in wpf there is a "*" value that does it by percentage.

this is a agreat wpf tutorial

http://www.wpftutorial.net/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜