WPF Demo13 GridSplitter

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WPF Demo13 GridSplitter相关的知识,希望对你有一定的参考价值。

<Window x:Class="Commands.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" ResizeMode="CanResize" ShowInTaskbar="True">
    <Window.CommandBindings>
        <CommandBinding Command="Save" Executed="Save_Executed" CanExecute="Save_CanExecute"/>
        <CommandBinding Command="Close" Executed="Close_Executed" CanExecute="Close_CanExecute"/>
    </Window.CommandBindings>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="5"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>

        <!--Background="#00000000" 透明色设置-->
        <Menu Grid.Row="0" Grid.ColumnSpan="3">
           
            <MenuItem Header="保存" Command="Save"/>
            <MenuItem Header="关闭" Command="Close"/>
        </Menu>
        
        <ToolBar Grid.Row="1" Grid.ColumnSpan="3">
            <Button>
                <Image Source="image/Copy.png"/>
            </Button>
            <Button>
                <Image Source="image/Paste.png"/>
            </Button>
            <Button>
                <Image Source="image/Cut.png"/>
            </Button>
            <Button>
                <Image Source="image/Delete.png"/>
            </Button>
        </ToolBar>
        <TextBox Grid.Row="2"   Name="txtLeft" TextChanged="txtLeft_TextChanged">
            <TextBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="复制" >
                        <MenuItem.Icon>
                            <Image Source="/Commands;component/image/Copy.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="粘贴">
                        <MenuItem.Icon>
                            <Image Source="/Commands;component/image/Paste.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="剪贴">
                        <MenuItem.Icon>
                            <Image Source="/Commands;component/image/Cut.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="删除">
                        <MenuItem.Icon>
                            <Image Source="/Commands;component/image/Delete.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </TextBox.ContextMenu>
        </TextBox>
        <GridSplitter Grid.Row="2"   Grid.Column="1" Width="5" Background="GhostWhite" HorizontalAlignment="Stretch" />
        <TextBlock Grid.Column="2" Grid.Row="2"  Name="txtRight" />
        <StatusBar Grid.Row="3"  Name="statusBar1"  Grid.ColumnSpan="3" >
            <StatusBarItem Content="当前状态为:" />
            <Label Content="default"/>
        </StatusBar>
    </Grid>
</Window>

技术分享

以上是关于WPF Demo13 GridSplitter的主要内容,如果未能解决你的问题,请参考以下文章

WPF GridSplitter 使用技巧

用户使用 GridSplitter 后 WPF 行高绑定停止工作

C#/WPF Grid和GridSplitter布局问题。

WPF GridSplitter Column Width="Auto" 时的奇怪行为

WPF 复合控件焦点设置

wpf里面如何用画线把两个grid连接起来