wpf - GridSplitter

There is a GridSplitter class which helps modify the width or height of a control of on the form.Normally you will embed some GridSplitter to give some resize ability to Controls enclosed in a Grid layout control. 

Below is a use case of the GridSpliiter, The ResizeDirection controls the orientation; you might watch for the VerticalAlignment/HorizontalAlignment because normally a GridSplitter has width/height of observable small.. 

<Window x:Class="ControlTemplateExplorer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="2"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

            <ListView x:Name="listTypes" Grid.Column="0" Grid.Row="0" DisplayMemberPath="Name" SelectionChanged="listTypes_SelectionChanged"/>
        
        <GridSplitter 
            ResizeDirection="Columns"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            ShowsPreview="True"
            Grid.Column="1"
            />
        <!-- ViewBox ??-->
        <!-- DocumentViewer ??-->
        <!--http://stackoverflow.com/questions/1981137/c-sharp-wpf-scrollviewer-textblock-troubles-->
        <ScrollViewer  Grid.Column="2" Grid.Row="0"
                       HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" 
                       x:Name="Scroller"
                       >
            <TextBox x:Name="txtTemplate" 
                     HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                     MinWidth="100" Width="{Binding ElementName=Scroller, Path=ViewportWidth}" TextWrapping="Wrap"
                     />
        </ScrollViewer>

        <Grid x:Name="grid" Visibility="Collapsed" >
        </Grid>
    </Grid>
</Window>


Tell the difference between the GridSplitter and the Separator.. 



你可能感兴趣的:(WPF)