コントロールを使用して、XAML でブレッドクラムを作成しましたListBox
。それはうまく機能します。ただし、あまりにも多くのアイテムを追加して表示しようとすると、当然、それらの一部しか表示されません。右側の要素が表示されるまで、左側のアイテムをどうにかして非表示にしたいと考えています。理想的には、空き領域 (右側) も残しておく必要があります。これどうやってするの?
<ListBox Height="80" HorizontalAlignment="Stretch" x:Name="breadcrumb"
MinWidth="300" Background="Transparent" BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="8,0,0,0" Orientation="Horizontal" HorizontalAlignment="Stretch" Background="Transparent">
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="#111"/>
<Setter Property="BorderBrush" Value="#AAA"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<StackPanel Orientation="Horizontal" Margin="-8,0,0,0">
<Image Source="Assets/breadcrumb.png" VerticalAlignment="Center" Margin="5,0,0,0"/>
<ContentPresenter />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Stretch">
<TextBlock FontSize="35" Text="{Binding Name}" VerticalAlignment="Center" Padding="5,10"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>