3 つのラベルが付いたステータスバーがあります。ラベルのテキストが多すぎて画面に収まらない場合があります。画面に収まらないテキストが表示されるように、各ラベルのテキストをドラッグ アンド スライドできるようにしたいと考えています。
ラベルでこれを行う方法はありますか? または、このために何らかのカスタム スライド パネルを作成する必要がありますか?
カスタム パネルを作成する必要がある場合、テキストのスライドをアニメーション化する方法を教えてもらえますか?
3 つのラベルが付いたステータスバーがあります。ラベルのテキストが多すぎて画面に収まらない場合があります。画面に収まらないテキストが表示されるように、各ラベルのテキストをドラッグ アンド スライドできるようにしたいと考えています。
ラベルでこれを行う方法はありますか? または、このために何らかのカスタム スライド パネルを作成する必要がありますか?
カスタム パネルを作成する必要がある場合、テキストのスライドをアニメーション化する方法を教えてもらえますか?
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>
これがステータスバーとスプリッターのあるウィンドウです。トリックは、スプリッターが移動してサイズを変更できるようにするには、テキストブロックの列を Auto に設定する必要があることです。コード ビハインドには何もありません。スプリッターがドラッグされたときに何かをしたい場合は、処理できる DragCompleted イベントがあります。