简体   繁体   English

在Windows 8 App Store中使用C#选择控件时更改边框颜色

[英]Changing border color when a control is selected with c# on windows 8 app store

I have a gridview control with images and text with this xaml: 我有一个带有此xaml的图像和文本的gridview控件:

<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 我在下面的GridView中的所选项目周围得到了紫色边框

在图像周围选择紫色边框颜色

How can i override this behaviour, i need to change the color to a custom color (#fdeb01). 我该如何改写这种行为,我需要将颜色更改为自定义颜色(#fdeb01)。

You could edit the ItemContainerStyle for the GridView. 您可以编辑GridView的ItemContainerStyle。 The easiest way is to use Blend and find the SelectedBorder element and change stroke brush to color you want. 最简单的方法是使用Blend并找到SelectedBorder元素,然后将笔刷更改为所需的颜色。

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

寻找SelectedBorder元素

将描边笔刷更改为自定义颜色

而且你应该看到这样的东西

Aside from using Expression Blend, note that Metro ListView selection color modification in XAML is also valid for GridViewItems so changing the following: 除了使用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>

will also affect the gridview. 也会影响gridview。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM