本文整理汇总了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));
}
示例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;
}
示例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;
}
}