Gridview标头转换不起作用? [英] Gridview Header Transitions not working?

查看:57
本文介绍了Gridview标头转换不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图弄清楚自己是否做错了什么,但除非有使用GridView分组标题转换的秘密,否则我想知道是否有错误。 他们没有做任何过渡。 添加和删​​除后,它们只会闪烁
。 要查看我的意思,请使用网格应用模板创建一个新项目。


在标题中粘贴两个按钮在GroupedItemsPage上的某个地方。 添加Tapped事件并让VS创建处理程序。 转至SampleDataSource类并添加以下两个静态方法:


<预类= "prettyprint">公共静态无效AddItemToFirstGroup(SampleDataItem项)
{
_sampleDataSource.AllGroups [ 0] .Items.Add(项目);
}

public static void AddGroup(SampleDataGroup group)
{
_sampleDataSource.AllGroups.Insert(0,group);
}

返回GroupedItemsPage代码隐藏到  tapped按钮 事件处理程序并插入以下内容:

私人无效Button_Tapped_1(对象发件人,TappedRoutedEventArgs E)
{
SampleDataItem项=新SampleDataItem(QUOT;试验","试验","!字幕","" ,"","",null);
SampleDataSource.AddItemToFirstGroup(item);
}

私人无效Button_Tapped_2(对象发件人,TappedRoutedEventArgs E)
{
SampleDataGroup组=新SampleDataGroup(QUOT;试验"," testGroup"," subtitle","","");
group.Items.Add(new SampleDataItem("test","test!","subtitle",""","","""
SampleDataSource.AddGroup(group);
}

最后,就我所知,这并没有任何意义,请转到Gridview xaml声明并在主要属性下方添加以下内容:

< GridView.HeaderTransitions> 
< TransitionCollection>
< AddDeleteThemeTransition />
< ContentThemeTransition />
< RepositionThemeTransition />
< EntranceThemeTransition />
< / TransitionCollection>
< /GridView.HeaderTransitions>

(我添加了一堆转换以查看是否有效果。)



因此,第一个按钮会将项目插入第一个组。 您可以清楚地看到AddDeleteThemeTransition。 第二个按钮在gridview的开头插入一个新组,其中包含一个项目。  (我选择插入而不是添加 因为
它总是在gridview末尾添加屏幕外。) 新组中的项目执行AddDeleteThemeTransition,但是组头除了闪烁之外什么都不做。


我还尝试使用Blend并编辑GroupStyle.ContainerStyle的副本并明确在内部添加转换到contentcontrol,但这也没有用。 


我做错了吗? 谢谢!!




Lee McPherson

解决方案

< BLOCKQUOTE>

尝试在组头模板加入过渡收集如下图所示,以获得最佳的出过渡动画&NBSP的;使用EdgeUIThemeTransition或PaneThemeTransition和使组头稍大内部的按钮(如大
作为GridView中的项目,您可以看到它从右向左移动。


 

< span style ="background:white; color:blue; font-family:Consolas; font-size:9.5pt">< GroupStyle.HeaderTemplate >


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&N BSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
    < DataTemplate >


           &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< Grid
保证金
=" 1,0,0, 6">


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< Grid.Transitions>


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< TransitionCollection>


< span style ="background:white; color:#00b050; font-family:Consolas; font-size:9.5pt">            &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;
< PaneThemeTransition Edge =" Right" />


       &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<! - < EdgeUIThemeTransition Edge =" Bottom" /> - >


   ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<! - < AddDeleteThemeTransition   /> - >


            ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;
<! - < ContentThemeTransition /> - >


      ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; 
<! - < RepositionThemeTransition /> - >


      &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<! - < EntranceThemeTransition /> - >


      ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< / TransitionCollection>


           ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< /Grid.Transitions>


        &NBSP;&NBSP;&NBSP;
<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; 
< Button
Width =" 250"


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
  AutomationProperties。姓名 =" Group Title"


  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
  点击 =" Header_Click"


    ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
  样式 =" { StaticResource
TextPrimaryButtonStyle
}" >


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< StackPanel
方向
="水平">


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< TextBlock
文字
=" { < span style ="background:white; color:#a31515; font-family:Consolas; font-size:9.5pt"> Binding
标题
}" Margin =" 3,-7,10,10"
S. tyle
=" { StaticResource
GroupHeaderTextStyle
}" />


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< TextBlock
Text
=" { StaticResource
ChevronGlyph
}" FontFamily =" Segoe
UI符号"
保证金 =" 0,-7,0,10"
样式
=" { StaticResource
GroupHeaderTextStyle
}" />


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;               
< / StackPanel >


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; 
           < / 按钮 >


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;       
< / 网格 >


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;   
< / DataTemplate >


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< / GroupStyle.HeaderTemplate >



祝你好运,


哈桑


I'm killing myself trying to figure out if I did anything wrong, but unless there's a secret to using the GridView grouped header transitions, I'm wondering if there's something wrong.  They don't do any transitions.  They just blink on and off when added and removed. To see what I mean, create a new project using the Grid App template.

Stick two button in the header somewhere on the GroupedItemsPage.  Add Tapped events and let VS create handlers.  Go to the SampleDataSource class and add the following two static methods:

public static void AddItemToFirstGroup(SampleDataItem item)
        {
            _sampleDataSource.AllGroups[0].Items.Add(item);
        }

        public static void AddGroup(SampleDataGroup group)
        {
            _sampleDataSource.AllGroups.Insert(0,group);
        }

Go back to the GroupedItemsPage codebehind to the tapped button event handlers and insert the following:

private void Button_Tapped_1(object sender, TappedRoutedEventArgs e)
        {
            SampleDataItem item = new SampleDataItem("test", "test!", "subtitle", "", "", "", null);
            SampleDataSource.AddItemToFirstGroup(item);
        }

        private void Button_Tapped_2(object sender, TappedRoutedEventArgs e)
        {
            SampleDataGroup group = new SampleDataGroup("test", "testGroup", "subtitle", "", "");
            group.Items.Add(new SampleDataItem("test", "test!", "subtitle", "", "", "", null));
            SampleDataSource.AddGroup(group);
        }

Finally, and this does NOTHING as far as I can tell, go to the Gridview xaml declaration and add the following just below the main attributes:

<GridView.HeaderTransitions>
                <TransitionCollection>
                    <AddDeleteThemeTransition />
                    <ContentThemeTransition />
                    <RepositionThemeTransition />
                    <EntranceThemeTransition />
                </TransitionCollection>
            </GridView.HeaderTransitions>

(I added a bunch of transitions to see if any had an effect.)

So the first button will insert an item into the first group.  You can clearly see the AddDeleteThemeTransition.  The second button inserts a new group with one item in it at the beginning of the gridview.  (I chose to insert instead of add because it will always add offscreen at the end of the gridview).  The item inside the new group does the AddDeleteThemeTransition, but the group header does nothing but blink on.

I've also tried to use Blend and edit a copy of the GroupStyle.ContainerStyle and explicitly add transitions to the contentcontrol within, but that didn't work either. 

Am I doing anything wrong?  Thanks!!


Lee McPherson

解决方案

Try adding the transition collection in the group header template as shown below and to get the best out of the transition animation use EdgeUIThemeTransition or PaneThemeTransition and make the button inside the group header little larger (as large as the items in the GridView so you can see it move from right to left.

 

<GroupStyle.HeaderTemplate>

                        <DataTemplate>

                            <Grid Margin="1,0,0,6">

                                <Grid.Transitions>

                                    <TransitionCollection>

                                        <PaneThemeTransition Edge="Right"/>

                                        <!--<EdgeUIThemeTransition Edge="Bottom"/>-->

                                        <!--<AddDeleteThemeTransition  />-->

                                        <!--<ContentThemeTransition />-->

                                        <!--<RepositionThemeTransition />-->

                                        <!--<EntranceThemeTransition />-->

                                    </TransitionCollection>

                                </Grid.Transitions>

                                <Button Width="250"

                                    AutomationProperties.Name="Group Title"

                                    Click="Header_Click"

                                    Style="{StaticResource TextPrimaryButtonStyle}" >

                                    <StackPanel Orientation="Horizontal">

                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />

                                        <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>

                                    </StackPanel>

                                </Button>

                            </Grid>

                        </DataTemplate>

                    </GroupStyle.HeaderTemplate>

Good luck,

Hassan


这篇关于Gridview标头转换不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆