2

I have a gridview control with images and text with this xaml:

<Grid Grid.Column="1" Margin="0,40,30,0" >
     <GridView x:Name="celebGridView" Margin="0,0,0,0" Padding="0,0,0,0">
             <GridView.ItemsPanel>
                 <ItemsPanelTemplate>
                     <WrapGrid Orientation="Horizontal" MaximumRowsOrColumns="3"/>
                 </ItemsPanelTemplate>
               </GridView.ItemsPanel>

               <GridView.Header>
                   <StackPanel Width="480" Margin="0,4,14,0">
                       <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
                          <TextBlock Text="Most Viewed Celebs" Foreground="black"                                       FontSize="25"/>
                           <Image Source="/images/Navigation-Right.png"  Margin="10,0,0,0"/>
                         </StackPanel>

                    </StackPanel>
                  </GridView.Header>

                   <GridView.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                        <Image Source="{Binding ImageBitmap}" />
                                        <TextBlock HorizontalAlignment="Center" Text="{Binding Name_}" Foreground="Black"/>
                                    </StackPanel>
                                </DataTemplate>
                            </GridView.ItemTemplate>
                        </GridView>
                    </Grid>

and i get this purple border around the selected items in the gridview below

selected purple border color around image

How can i override this behaviour, i need to change the color to a custom color (#fdeb01).

4

2 回答 2

4

您可以编辑 GridView 的 ItemContainerStyle。最简单的方法是使用 Blend 并找到 SelectedBorder 元素并将笔刷更改为您想要的颜色。

使用 Blend 打开 XAML 并创建/编辑 ItemContainerStyle

寻找 SelectedBorder 元素

将笔刷更改为自定义颜色

你应该看到这样的东西

于 2013-05-10T15:49:02.013 回答
1

除了使用 Expression Blend,请注意 XAML 中的 Metro ListView 选择颜色修改对 GridViewItems 也有效,因此更改以下内容:

<SolidColorBrush x:Key="ListViewItemSelectedBackgroundThemeBrush" Color="#fdeb01">     </SolidColorBrush>
<SolidColorBrush x:Key="ListViewItemPointerOverBackgroundThemeBrush" Color="#ffffff"></SolidColorBrush>
<SolidColorBrush x:Key="ListViewItemSelectedPointerOverBackgroundThemeBrush" Color="#fdeb01"></SolidColorBrush>
<SolidColorBrush x:Key="ListViewItemSelectedPointerOverBorderThemeBrush" Color="#fdeb01"></SolidColorBrush>

也会影响gridview。

于 2013-05-21T15:28:53.013 回答