将SemanticZoom内的GridView滚动到SemanticZoom外部的某个组

ken*_*trh 5 c# xaml microsoft-metro windows-8 semantic-zoom

我想添加自定义的字母选区外的SemanticZoom除了字母的选择ZoomedOutView,但我不能设法操纵GridViewZoomedInView

<code>ItemSource</code>,两个字母视图中的两个相同,并在代码隐藏中设置.</p>

<p>该<code>SemanticZoom</code>作品很好,但我想要做到的,是当点击右上角的一个字母,它滚动到相应的组中<code>ZoomedInView</code>.</p>

<p>有没有办法实现这个目标?</p>

<p>(我没有包含任何代码,因为代码本身不是主要问题,但请告知我是否应该包含它)</p></p>
    </div>
  </div>

<div class=

Ano*_*bik 1

最后我想出了一个解决方法。我给出了代码,但在此之前从 msdn 链接下载 Gridview 示例。

网格视图示例

要查看效果的更改需要在ScenarioOutput1.xamlScenarioOutput1.xaml.cs中完成。

那么让我们从我更改的 ScenarioOutput1.xaml 代码开始,如果您对代码理解有困难,请将其复制粘贴到项目中(来自 msdn 的 GridView 演示)以查看效果。

场景输出1.xaml

    <Page
    x:Class="ListViewSimple.ScenarioOutput1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <Grid Height="300" VerticalAlignment="Top" Tapped="Grid_Tapped">
        <ScrollViewer x:Name="scroller" HorizontalScrollMode="Enabled" Width="auto" HorizontalScrollBarVisibility="Visible">
            <GridView x:Name="ItemGridView" Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
            ItemTemplate="{StaticResource StoreFrontTileTemplate}"
            ItemContainerStyle="{StaticResource StoreFrontTileStyle}"
            ItemsPanel="{StaticResource StoreFrontGridItemsPanelTemplate}"
            BorderBrush="LightGray"
            VerticalAlignment="Top"
                      ScrollViewer.HorizontalScrollBarVisibility="Hidden"
            BorderThickness="1" ScrollViewer.VerticalScrollBarVisibility="Auto"
            SelectionMode="None"/>

        </ScrollViewer>
    </Grid>
</Page>
Run Code Online (Sandbox Code Playgroud)

现在下一部分是 cs 文件。

ScenarioOutput1.xaml.cs

using System;
using System.Linq;
using System.Collections.Generic;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using SDKTemplateCS;
using Expression.Blend.SampleData.SampleDataSource;

namespace ListViewSimple
{
    public sealed partial class ScenarioOutput1 : Page
    {
        // A pointer back to the main page which is used to gain access to the input and output frames and their content.
        MainPage rootPage = null;
        StoreData storeData = null;
        private Item item;
        private Expression.Blend.SampleData.SampleDataSource.ItemCollection _collectionNew = new Expression.Blend.SampleData.SampleDataSource.ItemCollection();
        public ScenarioOutput1()
        {
            InitializeComponent();

            storeData = new StoreData();
            ItemGridView.ItemsSource = storeData.Collection;
        }

        #region Template-Related Code - Do not remove
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Get a pointer to our main page.
            rootPage = e.Parameter as MainPage;

            // We want to be notified with the OutputFrame is loaded so we can get to the content.
            rootPage.InputFrameLoaded += new System.EventHandler(rootPage_InputFrameLoaded);
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            rootPage.InputFrameLoaded -= new System.EventHandler(rootPage_InputFrameLoaded);
        }
        #endregion

        #region Use this code if you need access to elements in the input frame - otherwise delete
        void rootPage_InputFrameLoaded(object sender, object e)
        {
            // At this point, we know that the Input Frame has been loaded and we can go ahead
            // and reference elements in the page contained in the Input Frame.

            // Get a pointer to the content within the IntputFrame.
            Page inputFrame = (Page)rootPage.InputFrame.Content;

            // Go find the elements that we need for this scenario
            // ex: flipView1 = inputFrame.FindName("FlipView1") as FlipView;
        }
        #endregion

        Uri _baseUri = new Uri("ms-appx:///");
        private DispatcherTimer _timer;
        private async void Grid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            try
            {
                item = new Item();
                item.Title = "This is a new One First";
                item.SetImage(_baseUri, "SampleData/Images/60SprinklesRainbow.png");
                item.Subtitle = "Ultrices rutrum sapien vehicula semper lorem volutpat sociis sit maecenas praesent taciti magna nunc odio orci vel tellus nam sed accumsan iaculis dis est";
                item.Link = "http://www.blueyonderairlines.com/";
                item.Category = "Ice Cream";
                item.Description = "Consectetuer lacinia vestibulum tristique sit adipiscing laoreet fusce nibh suspendisse natoque placerat pulvinar ultricies condimentum scelerisque nisi ullamcorper nisl parturient vel suspendisse nam venenatis nunc lorem sed dis sagittis pellentesque luctus sollicitudin morbi posuere vestibulum potenti magnis pellentesque vulputate mattis mauris mollis consectetuer pellentesque pretium montes vestibulum condimentum nulla adipiscing sollicitudin scelerisque ullamcorper pellentesque odio orci rhoncus pede sodales suspendisse parturient viverra curabitur proin aliquam integer augue quam condimentum quisque senectus quis urna scelerisque nostra phasellus ullamcorper cras duis suspendisse sociosqu dolor vestibulum condimentum consectetuer vivamus est fames felis suscipit hac";
                item.Content = "aaaA";

                _collectionNew.Add(item);

                item = new Item();
                item.Title = "This is a new One Second";
                item.Subtitle = "Ultrices rutrum sapien vehicula semper lorem volutpat sociis sit maecenas praesent taciti magna nunc odio orci vel tellus nam sed accumsan iaculis dis est";
                item.Link = "http://www.blueyonderairlines.com/";
                item.Category = "Ice Cream";
                item.SetImage(_baseUri, "SampleData/Images/60SprinklesRainbow.png");
                item.Description = "Consectetuer lacinia vestibulum tristique sit adipiscing laoreet fusce nibh suspendisse natoque placerat pulvinar ultricies condimentum scelerisque nisi ullamcorper nisl parturient vel suspendisse nam venenatis nunc lorem sed dis sagittis pellentesque luctus sollicitudin morbi posuere vestibulum potenti magnis pellentesque vulputate mattis mauris mollis consectetuer pellentesque pretium montes vestibulum condimentum nulla adipiscing sollicitudin scelerisque ullamcorper pellentesque odio orci rhoncus pede sodales suspendisse parturient viverra curabitur proin aliquam integer augue quam condimentum quisque senectus quis urna scelerisque nostra phasellus ullamcorper cras duis suspendisse sociosqu dolor vestibulum condimentum consectetuer vivamus est fames felis suscipit hac";
                item.Content = "aaaa";

                _collectionNew.Add(item);
                scroller.ScrollToHorizontalOffset(2000);
                _timer = new DispatcherTimer();
                _timer.Interval = new TimeSpan(3000);
                _timer.Tick += _timer_Tick;
                _timer.Start();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        void _timer_Tick(object sender, object e)
        {
            ItemGridView.ItemsSource = null;
            ItemGridView.ItemsSource = _collectionNew;
                 _timer.Stop();
        }
    }


}
Run Code Online (Sandbox Code Playgroud)

请在demo中实现一下,看看效果。可能还有其他解决方法,但希望尽快轻松地清除这些内容。如果您在理解上遇到任何困难,请告诉我:)