Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将SemanticZoom内的GridView从SemanticZoom外滚动到特定组_C#_Xaml_Windows 8_Microsoft Metro_Semantic Zoom - Fatal编程技术网

C# 将SemanticZoom内的GridView从SemanticZoom外滚动到特定组

C# 将SemanticZoom内的GridView从SemanticZoom外滚动到特定组,c#,xaml,windows-8,microsoft-metro,semantic-zoom,C#,Xaml,Windows 8,Microsoft Metro,Semantic Zoom,除了在ZoomedOutView中的字母选择之外,我正在尝试在SemanticZoom之外添加自定义字母选择,但我无法在ZoomedInView中操作GridView ZoomedOutView右上角按字母顺序选择“> ZoomedInView右上角按字母顺序选择“> 到目前为止,两个按字母顺序排列的视图的ItemSource是相同的,并在代码隐藏中设置 SemanticZoom工作正常,但我试图实现的是,当单击右上角的一个字母时,它会滚动到ZoomedInView中的相应组 有没有办法做到这一

除了在
ZoomedOutView
中的字母选择之外,我正在尝试在
SemanticZoom
之外添加自定义字母选择,但我无法在
ZoomedInView
中操作
GridView

ZoomedOutView右上角按字母顺序选择“>

ZoomedInView右上角按字母顺序选择“>

到目前为止,两个按字母顺序排列的视图的
ItemSource
是相同的,并在代码隐藏中设置

SemanticZoom
工作正常,但我试图实现的是,当单击右上角的一个字母时,它会滚动到
ZoomedInView
中的相应组

有没有办法做到这一点


(我没有包括任何代码,因为代码本身不是这里的主要问题,但请让我知道是否应该包括它)

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

并在ScenarioOutput1.xamlScenarioOutput1.xaml.cs中进行更改以查看效果

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

ScenarioOutput1.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>

请在演示中实现它并查看效果。可能还有其他的解决办法,但希望尽快轻松地清理这些东西。如果您在理解上有任何困难,请告诉我:)

项目源是否只包含D和E字母的数据,还是填充所有数据?@Anobik它包含所有数据。现在,我更新了项目源,在点击时只显示相应的字母,但这需要一个重置按钮,在点击一个项目后再次显示所有项目,这是不可取的。这个解决方案也会弄乱zoomedOutView。所以基本上你需要两件事1-创建一个滚动效果2-用相应的字母更新itemsource?在放大的视图中?我说得对吗?然后我会继续做一些变通办法作为答案。@Anobik是的,听起来不错!:)非常感谢。请检查解决方案。演示类型,但会让您的概念更清晰:)
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();
        }
    }


}