如何摆脱GridView UWP的框选择边框

时间:2016-03-13 19:03:19

标签: c# windows-phone-8.1 win-universal-app

我有这个gridview工作正常,但每次我选择一个项目,我在项目周围有这条蓝线,如何删除它?

<GridView Margin="5,15,0,0"  x:Name="List" ItemsSource="{Binding}" SelectionChanged="List_SelectionChanged">
        <GridView.ItemTemplate>
            <DataTemplate>
                <Grid  Margin="11">
                    <StackPanel BorderBrush="Black" Orientation="Vertical">
                        <Image Width="150" Height="150" Source="{Binding Way}" />
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </GridView.ItemTemplate>
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <ItemsWrapGrid  MaximumRowsOrColumns="2" Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
    </GridView>

enter image description here

3 个答案:

答案 0 :(得分:1)

要删除GridView的选择蓝色边框,我们可以修改GridView的模板。要修改GridViewItem的模板,我们可以选择“文档大纲”中的GridView并右键单击,然后选择“编辑其他模板”→“编辑生成的项目容器(ItemContainerStyle)“→”编辑副本... “。

Style中,其中有一个ListViewItemPresenter

  

在为Windows 10开发时,在项目容器样式中使用 ListViewItemPresenter 而不是GridViewItemPresenterListViewGridView

有关详细信息,请参阅ListViewItemPresenter

项目周围的蓝线颜色由SelectedBackground="{ThemeResource SystemControlHighlightAccentBrush}"定义。我们可以设置SelectedBackground="Transparent",然后项目周围没有蓝线。

答案 1 :(得分:1)

我就是这样做的。虽然改变样式并不困难,但这需要大约99%的xaml(以及更多的代码)来完成。您必须删除SelectionChanged事件,指定DataTemplate的数据类型,并为每个项添加一个Tapped事件。

<GridView SelectionMode="None" ItemsSource="{Binding}" 
    <GridView.ItemTemplate>
        <DataTemplate x:DataType="YourType">
            <Grid  Tapped="Grid_Tapped_For_Every_Item">
               ...                   
            </Grid>
        </DataTemplate>
    </GridView.ItemTemplate>
    ...
</GridView>

in code file:

private void Grid_Tapped_For_Every_Item(object sender, TappedRoutedEventArgs e){

    var g = (Grid) sender;
    var myClass = (YourType)g.DataContext;
    //Do whatever you were going to do in the SelectionChanged event
} 

答案 2 :(得分:0)

以下内容为我修复了此问题:

$description = preg_replace('/<script*\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script*>/i','',$description);
$sujet->setDescription($description);
相关问题