本文整理汇总了C#中System.Windows.Controls.Border.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# Border.AddHandler方法的具体用法?C# Border.AddHandler怎么用?C# Border.AddHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Border
的用法示例。
在下文中一共展示了Border.AddHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_dragWidget = (Border)GetTemplateChild("PART_DragWidget");
if (_dragWidget != null)
{
_dragWidget.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(HeaderLeftMouseButtonDown), true);
_dragWidget.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderMouseLeftButtonUp), true);
_dragWidget.MouseMove += (o, e) => HeaderMouseMove(e);
}
CloseButton = (Button)GetTemplateChild("PART_CloseButton");
if (CloseButton != null)
CloseButton.Click += (o, e) => Close();
Overlay = GetTemplateChild("PART_Overlay") as Panel;
WindowRoot = GetTemplateChild("PART_WindowRoot") as Grid;
WindowRoot.RenderTransform = _moveTransform;
//TODO: move somewhere else
_parent = VisualTreeHelper.GetParent(this) as FrameworkElement;
_parent.SizeChanged += (o, ea) =>
{
Overlay.Height = ea.NewSize.Height;
Overlay.Width = ea.NewSize.Width;
};
ChangeVisualState();
}
示例2: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if( _dragWidget != null )
{
_dragWidget.RemoveHandler( UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler( HeaderLeftMouseButtonDown ) );
_dragWidget.RemoveHandler( UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler( HeaderMouseLeftButtonUp ) );
_dragWidget.MouseMove -= ( o, e ) => HeaderMouseMove( e );
}
_dragWidget = GetTemplateChild( "PART_DragWidget" ) as Border;
if( _dragWidget != null )
{
_dragWidget.AddHandler( UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler( HeaderLeftMouseButtonDown ), true );
_dragWidget.AddHandler( UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler( HeaderMouseLeftButtonUp ), true );
_dragWidget.MouseMove += ( o, e ) => HeaderMouseMove( e );
}
if( CloseButton != null )
CloseButton.Click -= ( o, e ) => Close();
CloseButton = GetTemplateChild( "PART_CloseButton" ) as Button;
if( CloseButton != null )
CloseButton.Click += ( o, e ) => Close();
WindowRoot = GetTemplateChild( "PART_WindowRoot" ) as Grid;
WindowRoot.RenderTransform = _moveTransform;
_parentContainer = VisualTreeHelper.GetParent( this ) as FrameworkElement;
_parentContainer.LayoutUpdated += ParentContainer_LayoutUpdated;
_parentContainer.SizeChanged += ParentContainer_SizeChanged;
//initialize our modal background width/height
_modalLayer.Height = _parentContainer.ActualHeight;
_modalLayer.Width = _parentContainer.ActualWidth;
//this is for XBAP applications only. When inside an XBAP the parent container has no height or width until it has loaded. Therefore
//we need to handle the loaded event and reposition the window.
if( System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted )
{
_parentContainer.Loaded += ( o, e ) =>
{
ExecuteOpen();
};
}
_root = GetTemplateChild( "Root" ) as Grid;
#if VS2008
FocusVisualStyle = null;
#else
Style focusStyle = _root.Resources[ "FocusVisualStyle" ] as Style;
if( focusStyle != null )
{
Setter focusStyleDataContext = new Setter( Control.DataContextProperty, this );
focusStyle.Setters.Add( focusStyleDataContext );
FocusVisualStyle = focusStyle;
}
#endif
_root.Children.Add( _modalLayerPanel );
}
示例3: OnApplyTemplate
public override void OnApplyTemplate()
{
if (IsInDesignMode) return;
if (this.Header == null)
{
var dictionary = Application.LoadComponent(new Uri("/SharedUI;component/Controls/Flyouts/FlyoutMessageBar.xaml", UriKind.Relative)) as ResourceDictionary;
if (dictionary != null && dictionary.Contains("FlyoutMessageBarDefaultHeader"))
{
this.Header = dictionary["FlyoutMessageBarDefaultHeader"];
}
}
var closeImage = this.GetTemplateChild("PART_CloseImage") as Image;
if (closeImage != null)
{
closeImage.AddHandler(Image.MouseEnterEvent, new MouseEventHandler(this.OnCloseMouseEnter));
closeImage.AddHandler(Image.MouseLeaveEvent, new MouseEventHandler(this.OnCloseMouseLeave));
closeImage.AddHandler(Image.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.OnCloseMouseDown));
closeImage.AddHandler(Image.MouseLeftButtonUpEvent, new MouseButtonEventHandler(this.OnCloseMouseUp));
}
_border = this.GetTemplateChild("border") as Border;
if (_border != null)
{
_border.AddHandler(Border.MouseLeftButtonUpEvent, new MouseButtonEventHandler(this.OnMouseUp));
}
_openAnimation = this.GetTemplateChild("openAnimation") as DoubleAnimation;
_closeAnimation = this.GetTemplateChild("closeAnimation") as DoubleAnimation;
this.SetTransformationDirection();
this.SetGeometry();
}