トップ回答者
ListBox中のListBoxでスクロール不具合

質問
-
お世話になっております。
TV番組表のようなデータを扱うために、水平方向にアイテムを並べるListBoxに、垂直方向にアイテムを並べるListBoxを配置したいとします。
また、ListBoxはカスタマイズしたいとします。下記は、それを意図して書いた基本形です。
<Window x:Class="MyListBox.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Width="200" Height="150"> <Window.Resources> <Style x:Key="MainListBox" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBox"> <ScrollViewer > <StackPanel IsItemsHost="True" Orientation="Horizontal"/> </ScrollViewer> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="SubListBox" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBox"> <ScrollViewer> <StackPanel IsItemsHost="True"/> </ScrollViewer> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <ListBox Style="{StaticResource MainListBox}"> <ListBox Style="{StaticResource SubListBox}"> <ListBoxItem Height="40">item1</ListBoxItem> <ListBoxItem Height="40">item2</ListBoxItem> <ListBoxItem Height="40">item3</ListBoxItem> <ListBoxItem Height="40">item4</ListBoxItem> <ListBoxItem Height="40">item5</ListBoxItem> </ListBox> <ListBox Style="{StaticResource SubListBox}"> <ListBoxItem Height="40">ITEM1</ListBoxItem> <ListBoxItem Height="40">ITEM2</ListBoxItem> <ListBoxItem Height="40">ITEM3</ListBoxItem> <ListBoxItem Height="40">ITEM4</ListBoxItem> <ListBoxItem Height="40">ITEM5</ListBoxItem> </ListBox> </ListBox> </Grid> </Window>
item5をクリックしようとすると、スクロール位置がTOPに戻ってしまい、item5を選択できません。
Style="{StaticResource SubListBox}" を指定しなければ、すなわち通常のListBoxだと問題ありません。
どうすれば解決できるでしょうか?
教えてください。よろしくお願いします。