关于GridSplitter的一些说明

<Window x:Class="WpfApplication1.GridSplitterWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="GridSplitterWindow" Height="300" Width="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1" Width="10" Background="Red" ShowsPreview="True" VerticalAlignment="Stretch" HorizontalAlignment="Center">
            <GridSplitter.PreviewStyle>
                <Style TargetType="Control">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Control">
                                <Rectangle Name="rect" Stroke="Navy" StrokeDashArray="2" StrokeThickness="1" Fill="YellowGreen" />
                                <ControlTemplate.Triggers>
                                    <EventTrigger RoutedEvent="MouseEnter">
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="rect" Storyboard.TargetProperty="Fill.Color" From="YellowGreen" To="Pink" AutoReverse="True" RepeatBehavior="Forever" Duration="0:0:0.5" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                    <EventTrigger RoutedEvent="MouseLeave">
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="rect" Storyboard.TargetProperty="Fill.Color" Duration="0:0:0.5" />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </GridSplitter.PreviewStyle>
        </GridSplitter>
    </Grid>
</Window>

<Window x:Class="WpfApplication1.SharedSizeScopeWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SharedSizeScopeWindow" Height="300" Width="300">
    <Grid Grid.IsSharedSizeScope="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition SharedSizeGroup="group" Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <GridSplitter Width="5" Grid.Column="1" Background="Red" HorizontalAlignment="Center" VerticalAlignment="Stretch" ResizeDirection="Columns" />
            <TextBlock Text="Column 1" />
            <TextBlock Grid.Column="2" Text="Column 2" />
        </Grid>
           
        <ListBox Grid.Row="1">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid ShowGridLines="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="group" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding}" Margin="5" />
                        <TextBlock Grid.Column="1" Text="{Binding}" Margin="5" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>   
            <ListBox.ItemsSource>
                <x:Array xmlns="clr-namespace:System;assembly=mscorlib" Type="{x:Type String}">
                    <String>Zhang San</String>
                    <String>Li Si</String>
                    <String>Wang Wu</String>
                </x:Array>
            </ListBox.ItemsSource>
        </ListBox>
    </Grid>
</Window>


知识共享许可协议
《关于GridSplitter的一些说明》常伟华 创作。
采用 知识共享 署名-相同方式共享 3.0 中国大陆 许可协议进行许可。
  • 多说评论
  • 签名
  • 新浪微博
  • 默认评论
  • Tab Header 5

0 条评论 / 点击此处发表评论

Tab Content 5

开发技术


开发平台和工具

sitemap     155.61ms