本文整理汇总了C#中Windows.UI.Xaml.Controls.Button.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# Button.AddHandler方法的具体用法?C# Button.AddHandler怎么用?C# Button.AddHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.Button
的用法示例。
在下文中一共展示了Button.AddHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadKeyboard
/// <summary>Load a specific keyboard from its definition file.</summary>
/// <param name="uri">The location of the keyboard definition file.</param>
/// <param name="style">The style to use for a keyboard key.</param>
/// <returns>An async task,</returns>
private async Task LoadKeyboard(Uri uri, Style style)
{
var file = await StorageFile.GetFileFromApplicationUriAsync(uri);
using (var stream = await file.OpenStreamForReadAsync())
{
var textReader = (TextReader)new StreamReader(stream);
string line;
Dictionary<int, KeyInfo> allkeys = new Dictionary<int, KeyInfo>();
var hasAltGrKey = false;
var readKeys = false;
var readDeadKeys = false;
while (null != (line = await textReader.ReadLineAsync()))
{
if (string.IsNullOrWhiteSpace(line) ||
line.StartsWith("#"))
{
continue;
}
if (line == "[Keys]")
{
readKeys = true;
readDeadKeys = false;
}
else if (line == "[DeadKeys]")
{
readKeys = false;
readDeadKeys = true;
}
else if (readKeys)
{
int row, col, span;
var info = this.ReadKeyDefinition(line, out row, out col, out span);
if (info == null)
{
continue;
}
hasAltGrKey |= info.HasAltGrCode;
allkeys[info.Scancode] = info;
this.Invoke(() =>
{
var button = new Button();
button.Content = info[SymbolIndex.Normal].Label;
Grid.SetColumn(button, col);
Grid.SetRow(button, row);
Grid.SetColumnSpan(button, span);
button.Style = style;
button.Tag = info;
button.IsTabStop = false;
button.AddHandler(UIElement.PointerPressedEvent, (PointerEventHandler)this.ButtonPressed, true);
button.AddHandler(UIElement.PointerReleasedEvent, (PointerEventHandler)this.ButtonReleased, true);
button.AddHandler(UIElement.PointerExitedEvent, (PointerEventHandler)this.ButtonReleased, true);
this.MainGrid.Children.Add(button);
});
}
else if (readDeadKeys)
{
this.ReadDeadKeyDefinition(line, allkeys);
}
}
this.allKeys = allkeys;
this.usesAltGr = hasAltGrKey;
}
}