質問

私は基本的にこのようなUserControlをラップListBoxを持っている -

        <ListBox x:Name="lb" ItemsSource="{Binding ElementName=UC,Path=Pages}"
             Background="{Binding ElementName=UC,Path=Background}"
             BorderBrush="Transparent"
             ScrollViewer.CanContentScroll="False" 
             ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
             ScrollViewer.VerticalScrollBarVisibility="Disabled">

        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" IsItemsHost="True"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>

        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid Width="{Binding ElementName=UC,Path=ActualWidth}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="20"/>
                        <ColumnDefinition/>
                        <ColumnDefinition MinWidth="20"/>
                    </Grid.ColumnDefinitions>
                    <ContentPresenter Grid.Column="1" Content="{Binding}"/>
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

私は、この機能を非表示にするFocusVisualStyleする{x:Null}を設定する必要がありますが、私はそれを適用するに関係なく、私はまだ、デフォルト青選択色を取得します。私は、リストボックス、StackPanelのグリッド上ではなく、無駄にそれを設定しようとしました。

すべてのヘルプは素晴らしいことです。感謝ます。

役に立ちましたか?

解決

FocusVisualStyleは、集束要素ではなく、背景色の周りに「行進アリ」を適用します。以下のような何かを、選択したListBoxItemsの背景色を変更するには:

<ListBox>
    <ListBox.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Value="Red"/>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Value="Black"/>
    </ListBox.Resources>    
</ListBox>

他のヒント

ケントはFocusVisualStyleがTabキーでコントロールを選択したキーボード・フォーカス、にのみ関連している正しいです。

あなただけの任意の選択機能せずにリストを表示しようとしている場合は、

あなただけのItemsControl

にあなたのListBoxをダウングレードすることができるかもしれ
<ItemsControl x:Name="lb" ItemsSource="{Binding ElementName=UC,Path=Pages}" 
  Background="{Binding ElementName=UC,Path=Background}" 
  BorderBrush="Transparent" ScrollViewer.CanContentScroll="False" 
  ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
  ScrollViewer.VerticalScrollBarVisibility="Disabled">
  <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" IsItemsHost="True"/>
        </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>
  <!-- others -->
</ItemsControl>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top