WPF ListView / GridView突出显示颜色

时间:2011-05-21 06:53:30

标签: wpf listview gridview

XAML

    <ListView Name="Panel"
              Width="Auto"
              Margin="0,200,0,0"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch"
              Background="{x:Null}"
              BorderThickness="0"
              ItemsSource="{Binding Source={x:Static Communicator:Profile.AvailableFriends}}"
              MouseDoubleClick="Panel_MouseDoubleClick"
              ScrollViewer.HorizontalScrollBarVisibility="Disabled"
              SelectionMode="Single">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
        <ListView.View>
            <GridView ColumnHeaderContainerStyle="{StaticResource HiddenStyle}">
                <GridViewColumn Width="Auto">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Border Canvas.Left="55"
                                    Canvas.Top="30"
                                    Width="50"
                                    Height="50"
                                    Margin="0,5"
                                    BorderBrush="#FF3E5998"
                                    BorderThickness=".25"
                                    CornerRadius="9">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="5"
                                                      Opacity=".5"
                                                      ShadowDepth="3" />
                                </Border.Effect>
                                <Border BorderBrush="{Binding Color}"
                                        BorderThickness="3"
                                        CornerRadius="7.5">
                                    <Border BorderBrush="#FF3B5998"
                                            BorderThickness=".25"
                                            CornerRadius="6.5">
                                        <Border.Background>
                                            <ImageBrush ImageSource="{Binding Picture}" />
                                        </Border.Background>
                                    </Border>
                                </Border>
                            </Border>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Width="Auto">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Label Content="{Binding Name}" />
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>


如何:

1 - 更改突出显示鼠标悬停项目的颜色
2 - 更改所选项目的颜色 3 - 更改突出显示焦点选定项目的颜色

注意:

我尝试过多次改变颜色,但GRIDVIEW总是强迫自己:S

1 个答案:

答案 0 :(得分:0)

您需要更改ListViewItem模板。