当前位置: 首页>>代码示例>>C#>>正文


C# ViewModels.GetType方法代码示例

本文整理汇总了C#中ViewModels.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ViewModels.GetType方法的具体用法?C# ViewModels.GetType怎么用?C# ViewModels.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ViewModels的用法示例。


在下文中一共展示了ViewModels.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsPinned

 public async Task<bool> IsPinned(ViewModels.DetailPageViewModel vm)
 {
     if (vm == null)
         throw new ArgumentNullException(nameof(vm));
     var tileId = vm.GetType().ToString();
     var all = await SecondaryTile.FindAllAsync();
     return all.Any(x => x.TileId.Equals(tileId));
 }
开发者ID:ravindrapro,项目名称:Template10,代码行数:8,代码来源:TileService.cs

示例2: NextViewModelType

        public Type NextViewModelType(ViewModels.TestViewModel currentViewModel)
        {
            var index = All.IndexOf(currentViewModel.GetType());
            var nextIndex = index + 1;
            if (nextIndex < All.Count)
                return All[nextIndex];

            return null;
        }
开发者ID:knezik,项目名称:gina-api-examples,代码行数:9,代码来源:AllTestsService.cs

示例3: PinAsync

        public async Task<bool> PinAsync(ViewModels.DetailPageViewModel vm)
        {
            if (vm == null)
                throw new ArgumentNullException(nameof(vm));
            try
            {
                // prep for custom tile
                var folder = await Windows.ApplicationModel.Package.Current
                    .InstalledLocation.GetFolderAsync("Services");
                folder = await folder.GetFolderAsync("TileService");
                var file = await folder.GetFileAsync("DetailTile.xml");
                var xml = XDocument.Load(file.Path);
                var visualElement = xml.Descendants("visual").First();
                var bindingElements = visualElement.Descendants("binding").ToArray();

                // medium
                {
                    // fetch targets
                    var bindingElement = bindingElements[0];

                    var titleElement = bindingElement.Descendants("text").First();
                    titleElement.SetValue("Detail page (medium tile)");

                    var subtitleElement = bindingElement.Descendants("text").ToArray()[1];
                    subtitleElement.SetValue(vm.Value);
                }

                // wide
                {
                    // fetch targets
                    var bindingElement = bindingElements[1];

                    var imageElement = bindingElement.Descendants("image").First();
                    var imagePath = new Uri("ms-appx://Services/ToastService/Template10.png");
                    imageElement.SetAttributeValue("src", imagePath.ToString());

                    var titleElement = bindingElement.Descendants("text").First();
                    titleElement.SetValue("Detail page (medium tile)");

                    var subtitleElement = bindingElement.Descendants("text").ToArray()[1];
                    subtitleElement.SetValue(vm.Value);
                }

                // large
                {
                    // fetch targets
                    var bindingElement = bindingElements[2];

                    var imageElement = bindingElement.Descendants("image").First();
                    var imagePath = new Uri("ms-appx://Services/ToastService/Template10.png");
                    imageElement.SetAttributeValue("src", imagePath.ToString());

                    var titleElement = bindingElement.Descendants("text").First();
                    titleElement.SetValue("Detail page (wide tile)");

                    var subtitleElement = bindingElement.Descendants("text").ToArray()[1];
                    subtitleElement.SetValue(vm.Value);
                }

                // only one tile for this vm
                var tileId = vm.GetType().ToString();

                // initial pin
                if (!await IsPinned(vm))
                {
                    var secondaryTile = new SecondaryTile(tileId)
                    {
                        Arguments = vm.Value,
                        DisplayName = "Detail page",
                        VisualElements =
                        {
                            Square150x150Logo = new Uri("ms-appx:///Assets/Logo.png"),
                            ShowNameOnSquare150x150Logo = true,
                        },
                    };
                    if (!await secondaryTile.RequestCreateAsync())
                    {
                        System.Diagnostics.Debugger.Break();
                        return false;
                    }
                }

                // update pin
                var tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
                var tileNotification = new TileNotification(xml.ToXmlDocument());
                tileUpdater.Update(tileNotification);
                return true;
            }
            catch (Exception)
            {
                System.Diagnostics.Debugger.Break();
                return false;
            }
        }
开发者ID:ravindrapro,项目名称:Template10,代码行数:94,代码来源:TileService.cs


注:本文中的ViewModels.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。