Cri*_*urf 10 wpf xaml gridsplitter
我正在将WinForms应用程序迁移到WPF.到目前为止,一切都进展顺利,除了我尝试使用GridSplitter,我无法在运行时调整大小.
为了确保它不仅仅是我的代码,我试图从LearnWPF.com 编译GridSplitter示例,它似乎也不起作用.我希望看到标准的调整大小光标,当我将鼠标悬停在分割器上时没有发生,并且据我所知,窗口中的分割器也没有其他可视化表示.
我在这里错过了什么?
<Window x:Class="UI.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test" Height="300" Width="300">
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Background="#feca00" Grid.Column="0">
<TextBlock FontSize="35" Foreground="#58290A"
TextWrapping="Wrap">Left Hand Side</TextBlock>
</StackPanel>
<GridSplitter/>
<Border CornerRadius="10" BorderBrush="#58290A"
BorderThickness="5" Grid.Column="1">
<TextBlock FontSize="25" Margin="20" Foreground="#FECA00"
TextWrapping="Wrap">Right Hand Side</TextBlock>
</Border>
</Grid>
Run Code Online (Sandbox Code Playgroud)
mos*_*ald 12
在您的示例中,GridSplitter
将被放置在第一列中.我不记得我的WPF对齐规则,但我认为它可能放在第一列的左侧.不是你想要的.
GridSplitter
占用行或列比尝试与其他控件共享行或列要容易得多.
<Window x:Class="UI.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test" Height="300" Width="300">
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Background="#feca00">
<TextBlock FontSize="35" Foreground="#58290A" TextWrapping="Wrap">
Left Hand Side
</TextBlock>
</StackPanel>
<GridSplitter
Width="4"
Grid.Column="1"
Background="Red"
VerticalAlignment="Stretch"
HorizontalAlignment="Center"/>
<Border
Grid.Column="2"
BorderBrush="#58290A"
BorderThickness="5"
CornerRadius="10">
<TextBlock FontSize="25" Foreground="#FECA00" TextWrapping="Wrap">
Right Hand Side
</TextBlock>
</Border>
</Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7690 次 |
最近记录: |