本文整理匯總了C#中Windows.UI.Xaml.Controls.Grid.SetBinding方法的典型用法代碼示例。如果您正苦於以下問題:C# Grid.SetBinding方法的具體用法?C# Grid.SetBinding怎麽用?C# Grid.SetBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.Controls.Grid
的用法示例。
在下文中一共展示了Grid.SetBinding方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Parent_Tapped
private void Parent_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
if (SelectedTool == InkingToolMode.Annotate)
{
Point position = e.GetPosition(null);
// Find if we're intersecting with the toolbar, because we don't want annotation screens there.
IEnumerable<UIElement> intersectedElements = VisualTreeHelper.FindElementsInHostCoordinates(position, _inkToolbar);
// Check what elements of the sender we're on top of. If there's a button, we'll intersect with our toggle button collection
// to confirm whether we'd like to simply 'hittest' that button.
IEnumerable<UIElement> allIntersectedElements = VisualTreeHelper.FindElementsInHostCoordinates(position, (UIElement)sender);
// Not intersected with the toolbar and no togglebuttons (of ours) in the way indicating there's another annotation, go ahead
// and create the XAML.
if (intersectedElements.Count() == 0 && (AnnotationTogglers.Intersect(allIntersectedElements.OfType<ButtonBase>())).Count() == 0)
{
var panel = new Grid { Width = 300, Height = 200 };
StackPanel collapsingPanel = new StackPanel { Orientation = Orientation.Horizontal };
var toggleButtonText = new TextBlock { DataContext = this, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
var toggleButtonId = "tb" + Guid.NewGuid().ToString();
var toggleButtonContent = new Grid();
toggleButtonContent.Children.Add(toggleButtonText);
toggleButtonContent.Children.Add(new FontIcon { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\uE70B" });
var toggleButton = new ToggleButton { Content = new Viewbox { Child = toggleButtonContent }, Name = toggleButtonId, RenderTransform = new TranslateTransform { X = -10 }, Width = 32, Height = 32, Template = null, VerticalAlignment = VerticalAlignment.Top };
toggleButton.AddHandler(ToggleButton.PointerPressedEvent, new PointerEventHandler(ToggleButton_PointerPressed), true);
toggleButton.AddHandler(ToggleButton.PointerReleasedEvent, new PointerEventHandler(ToggleButton_PointerReleased), true);
toggleButton.AddHandler(ToggleButton.PointerMovedEvent, new PointerEventHandler(ToggleButton_PointerMoved), true);
toggleButton.PointerReleased += ToggleButton_PointerReleased;
AnnotationTogglers.Add(toggleButton);
toggleButtonText.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath("AnnotationTogglers"), Converter = listIndexerConverter, ConverterParameter = toggleButtonId, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
collapsingPanel.Children.Add(toggleButton);
var innerGrid = new Grid();
CommandBar richTextEditBar = new CommandBar();
var boldButton = new AppBarButton { Label = "Bold", Icon = new SymbolIcon(Symbol.Bold) };
// TODO: remove when destroyed
boldButton.Click += BoldButton_Click;
richTextEditBar.PrimaryCommands.Add(boldButton);
var italicButton = new AppBarButton { Label = "Italic", Icon = new SymbolIcon(Symbol.Italic) };
// TODO: remove when destroyed
italicButton.Click += ItalicButton_Click;
richTextEditBar.PrimaryCommands.Add(italicButton);
innerGrid.Children.Add(new RichEditBox { Header = richTextEditBar, Width = 200 });
var deleteIcon = new FontIcon { Name = "deleteIcon", FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\uE74D", Margin = new Thickness(0, 0, 5, 5), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom };
deleteIcon.Tapped += new Windows.UI.Xaml.Input.TappedEventHandler((o, a) => { DeleteAnnotation(panel); });
innerGrid.Children.Add(deleteIcon);
innerGrid.SetBinding(Grid.VisibilityProperty, new Binding { ElementName = toggleButton.Name, Path = new PropertyPath("IsChecked"), Converter = booleanToVisibilityConverter });
collapsingPanel.Children.Add(innerGrid);
panel.Children.Add(collapsingPanel);
Canvas.SetLeft(panel, position.X);
Canvas.SetTop(panel, position.Y);
_annotationCanvas.Children.Add(panel);
}
}
}