1

Вообщем, долго я блуждал по просторам (в основном англоязычным) интернета, так и не нашел ответа. Как мне убрать стандартное выделение с элемента ListView?

           <Style TargetType="ListView">
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="Background" Value="#FFFFFF"></Setter>
                <Setter Property="BorderThickness" Value="0"></Setter>
                <Setter Property="ItemTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <Grid Background="White">
                                <ContentPresenter Content="{Binding}"/>
                            </Grid>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="ItemContainerStyle">
                    <Setter.Value>
                        <Style TargetType="{x:Type ListBoxItem}">
                            <Setter Property="SnapsToDevicePixels" Value="True"/>
                            <Setter Property="Padding" Value="2,0,0,0"/>
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="BorderBrush" Value="Transparent"/>
                            <Setter Property="BorderThickness" Value="1"/>
                            <Setter Property="TextElement.Foreground" Value="{StaticResource Brush1}"/>
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                        <Border
                                            BorderBrush="Transparent"
                                            BorderThickness="0"
                                            Background="{TemplateBinding Background}"
                                            Padding="{TemplateBinding Padding}"
                                            SnapsToDevicePixels="true">
                                            <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Width="Auto" Margin="0" Content="{TemplateBinding Content}"/>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsMouseOver" Value="True"/>
                                                </MultiTrigger.Conditions>
                                                <Setter Property="Background" Value="#F5F5F5"/>
                                            </MultiTrigger>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="Selector.IsSelectionActive" Value="False"/>
                                                    <Condition Property="IsSelected" Value="True"/>
                                                </MultiTrigger.Conditions>
                                                <Setter Property="Background" Value="Transparent"/>
                                            </MultiTrigger>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                                    <Condition Property="IsSelected" Value="True"/>
                                                </MultiTrigger.Conditions>
                                                <Setter Property="Background" Value="#A0A0A0"/>
                                            </MultiTrigger>
                                            <Trigger Property="IsEnabled" Value="false">
                                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Setter.Value>
                </Setter>
                <Style.Resources>
                    <Style TargetType="ListBoxItem">
                        <Style.Resources>
                            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                            <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
                            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                        </Style.Resources>
                    </Style>
                    <Style TargetType="GridViewColumnHeader">
                        <Setter Property="Visibility" Value="Collapsed" />
                    </Style>
                </Style.Resources>
            </Style>

Получается вот такая штука:

Кто-то может мне объяснить:

  1. Почему текст в элементах синий? Как его поменять?
  2. Как убрать этот синий прямоугольник? (у меня он нигде не прописан)

PS: Brush1 - серая кисть

PSS: Это мой первый вопрос на сайте. Простите, если что-то не так

0

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.