我有一个带有三个标签的状态栏。有时标签必须有很多文本才能在屏幕上显示。我希望能够拖动和滑动每个标签中的文本,以显示不适合屏幕的文本。
有没有办法在标签中做到这一点?或者我应该为此创建某种类型的自定义滑动面板?
如果我必须创建一个自定义面板,是否可以为我提供一些关于如何为文本滑动设置动画的方向?
我有一个带有三个标签的状态栏。有时标签必须有很多文本才能在屏幕上显示。我希望能够拖动和滑动每个标签中的文本,以显示不适合屏幕的文本。
有没有办法在标签中做到这一点?或者我应该为此创建某种类型的自定义滑动面板?
如果我必须创建一个自定义面板,是否可以为我提供一些关于如何为文本滑动设置动画的方向?
好的,看到 GridSplitter 不是大多数示例的控件,我在 WPF 项目上做了一个示例:
<Window x:Class="ScrollBarsSplitter.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ScrollBarsSplitter"
mc:Ignorable="d"
Title="MainWindow" Height="640" Width="1024">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Test the Title" Background="Navy" Foreground="White" Padding="4" FontSize="14" />
<TextBlock Grid.Row="1" Text="Test contents" Background="White" Foreground="Navy" Padding="4" FontSize="14" />
<StatusBar Grid.Row="2" MinHeight="48" Background="Aquamarine">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="This is the text of the first panel of the grid" Margin="10 2 10 2" VerticalAlignment="Center"/>
<GridSplitter Grid.Column="1" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Stretch" Background="Red" VerticalAlignment="Stretch" MinHeight="48"/>
<TextBlock Grid.Column="2" Text="This is the text of the second panel of the grid" Margin="10 2 10 2" VerticalAlignment="Center"/>
<GridSplitter Grid.Column="3" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Red" MinHeight="48"/>
<TextBlock Grid.Column="4" Text="This is the text of the third panel of the grid" Margin="10 2 10 2" VerticalAlignment="Center"/>
</Grid>
</StatusBar>
</Grid>
这是带有状态栏和拆分器的窗口,诀窍是您必须将文本块列设置为自动,以便拆分器能够移动和更改大小我使用了一些难看的颜色来使内容可见。在后面的代码中没有任何内容,如果您想在拖动拆分器时执行某些操作,则可以处理 DragCompleted 事件。