routedevent

WPF FrameworkElement not receiving Mouse input

半腔热情 提交于 2020-06-25 08:33:46
问题 Trying to get OnMouse events appearing in a child FrameworkElement . The parent element is a Panel (and the Background property is not Null). class MyFrameworkElement : FrameworkElement { protected override void OnMouseDown(MouseButtonEventArgs e) { // Trying to get here! base.OnMouseDown(e); } } public class MyPanel : Panel { protected override void OnMouseDown(MouseButtonEventArgs e) { // This is OK base.OnMouseDown(e); } } OnMouse never gets called, event is always unhandled and Snoop

WPF FrameworkElement not receiving Mouse input

帅比萌擦擦* 提交于 2020-06-25 08:33:12
问题 Trying to get OnMouse events appearing in a child FrameworkElement . The parent element is a Panel (and the Background property is not Null). class MyFrameworkElement : FrameworkElement { protected override void OnMouseDown(MouseButtonEventArgs e) { // Trying to get here! base.OnMouseDown(e); } } public class MyPanel : Panel { protected override void OnMouseDown(MouseButtonEventArgs e) { // This is OK base.OnMouseDown(e); } } OnMouse never gets called, event is always unhandled and Snoop

F# Event Handler using XAML markup

两盒软妹~` 提交于 2019-12-23 23:40:50
问题 Now that I have a Custom Routed Event, how can I specify a handler in XAML? <Window.Resources> <Style TargetType="Grid"> <Setter Property="funk:Tap.Handler" Value="{Binding TapHandler}"/> </Style> </Window.Resources> Allowing: UIElements to handle bubbling or tunneling RoutedEvents, not just the Controls raising them The use of implicit Styles, eliminating the need to wire the event for each UIElement of a certain Type Change of handler based on logic in ViewModel a View with no code-behind

Programmatically open context menu using UI automation?

徘徊边缘 提交于 2019-12-21 17:00:02
问题 I'm trying to implement a right click context menu using UI automation. Since UI automation does not have a native right click pattern I am adding an ExpandCollapse provider to the listview's AutomationPeer class and mapping the expand and collapse to opening and closing the context menu. My question, is there a better method of invoking the context menu that doesn't involve trying to instantiate a class with a private constructor? I can't use SendKeys with Shift-F10. I'd like to use the

Handled RoutedEvent continues to bubble up tree

假装没事ソ 提交于 2019-12-12 11:07:58
问题 I'm developing a TreeView based control and my double click event continues to bubble up my TreeViewItem nodes. The goal is to have the TreeViewItem expand or collapse when it is double clicked. I have a style that applies an event handler for the MouseDoubleClick event to each TreeViewItem . Here's the code that handles the event private void TreeViewItemDoubleClicked( object sender, RoutedEventArgs e ) { // Get the specific tree view item that was double clicked TreeViewItem treeViewItem =

Weird KeyUp behaviour (main form handles events from child?!)

 ̄綄美尐妖づ 提交于 2019-12-10 16:05:49
问题 The problem: KeyUp is handled by the grid in main window ( Grid_KeyUp ) Main window shows a child window (e.g. MessageBox.Show(...) ) User presses [Return] ( Keys.Return ) to close the MessageBox Main window actually GETS the KeyUp event from that keypress in MessageBox I have a very simple isolated sample that shows the problem I am having. Just create an empty WPF project and use this XAML: <Grid KeyUp="Grid_KeyUp"> <Button Click="Button_Click"></Button> </Grid> And the code-behind: public

Fading out a wpf window on close

拜拜、爱过 提交于 2019-11-28 19:22:54
I want to fade a window in/out in my application. Fading in occurs on Window.Loaded and I wanted to fade out on close ( Window.Closed or Window.Closing ). Fading in works perfectly, but Window.Closing is not allowed value for RoutedEvent property. What RoutedEvent should I be using for Close? <Window.Triggers> <EventTrigger RoutedEvent="Window.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2" FillBehavior="HoldEnd" /> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="Window.Closing">

Fading out a wpf window on close

醉酒当歌 提交于 2019-11-27 12:13:24
问题 I want to fade a window in/out in my application. Fading in occurs on Window.Loaded and I wanted to fade out on close ( Window.Closed or Window.Closing ). Fading in works perfectly, but Window.Closing is not allowed value for RoutedEvent property. What RoutedEvent should I be using for Close? <Window.Triggers> <EventTrigger RoutedEvent="Window.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2" FillBehavior="HoldEnd" />