本文整理汇总了C#中System.Windows.Controls.StackPanel.TransformToVisual方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.TransformToVisual方法的具体用法?C# StackPanel.TransformToVisual怎么用?C# StackPanel.TransformToVisual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.StackPanel
的用法示例。
在下文中一共展示了StackPanel.TransformToVisual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHeaderCore
protected virtual FrameworkElement CreateHeaderCore(string icon, IEnumerable<string> overlays, string header, bool isPublic)
{
var panel = new StackPanel { Orientation = Orientation.Horizontal };
var icons = new Grid();
var mainIcon = DefaultImages.AssemblyBrowser.GetDefaultImage(icon);
mainIcon.Width = 16;
mainIcon.Height = 16;
icons.Children.Add(mainIcon);
if (overlays != null)
{
foreach (var overlay in overlays)
icons.Children.Add(DefaultImages.AssemblyBrowser.GetDefaultImage(overlay));
}
panel.Children.Add(icons);
var caption = new TextBlock
{
Text = header,
Margin = new Thickness(5, 0, 0, 0),
FontWeight = FontWeights.Normal
};
if (!isPublic) caption.FontStyle = FontStyles.Italic;
panel.Children.Add(caption);
panel.MouseRightButtonDown += (s, e) => e.Handled = true;
panel.MouseRightButtonUp += (s, e) =>
{
IsSelected = true;
var menu = CreateContextMenu();
if (menu == null || menu.Items.Count == 0) return;
GeneralTransform gt = panel.TransformToVisual(Application.Current.RootVisual as UIElement);
Point offset = gt.Transform(new Point(0, 0));
menu.HorizontalOffset = offset.X + e.GetPosition(panel).X;
menu.VerticalOffset = offset.Y + e.GetPosition(panel).Y;
menu.IsOpen = true;
};
return panel;
}