frameworkelement

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

C# WPF Programatically created DataTemplate Dockpanel in Stackpanel has no effect

人盡茶涼 提交于 2020-01-15 08:20:19
问题 I'm trying to dynamically create a datatemplate for a listbox. This is for a Custom UserControl. This UserControl has a DependencyProperty which accepts any types of IEnumerable<> . This works fine... But the Output is always Property / Value Property / Value if the objects contains 2 Properties. But i want that the properties are arranged side by side. Like: Object 1: Porperty / Value Property / Value Object 2: Property / Value Property / Value So where am i wrong ? i'm making first a

C# WPF Programatically created DataTemplate Dockpanel in Stackpanel has no effect

匆匆过客 提交于 2020-01-15 08:18:08
问题 I'm trying to dynamically create a datatemplate for a listbox. This is for a Custom UserControl. This UserControl has a DependencyProperty which accepts any types of IEnumerable<> . This works fine... But the Output is always Property / Value Property / Value if the objects contains 2 Properties. But i want that the properties are arranged side by side. Like: Object 1: Porperty / Value Property / Value Object 2: Property / Value Property / Value So where am i wrong ? i'm making first a

WPF Binding FrameworkElement event to command

混江龙づ霸主 提交于 2020-01-14 03:29:11
问题 How can I bind a UserControl 's FrameworkElement event to a view model command? I use MVVM and Prism so clear separation between the view the view-model would be nice. I'd tried multiple things, and none of them worked: <i:Interaction.Triggers> <i:EventTrigger EventName="FrameworkElement.Unloaded"> <i:InvokeCommandAction Command="{Binding Unloaded}" /> </i:EventTrigger> </i:Interaction.Triggers> also using this tutorial http://blog.functionalfun.net/2008/09/hooking-up-commands-to-events-in

Behavior of DependencyProperty With Regards to Multiple FrameworkElement Instances

*爱你&永不变心* 提交于 2020-01-10 04:31:04
问题 So I tried using DependencyProperty to solve my issues with regards to passing the local ViewModel across child Views. However a question popped in my head. For example I need to make multiple instances of a certain FrameworkElement , say, a UserControl . That UserControl has a DependencyProperty defined. As stated in books, a dependency property instance should be static and readonly . How would the DependencyProperty work in that kind of scenario? Would it work the same way as a

FrameworkElement.Name problem

℡╲_俬逩灬. 提交于 2019-12-30 17:52:40
问题 I am attempting to set the Name property of a Page in the constructor: public partial class PageListView : Page { public PageListView(string title) { InitializeComponent(); Name = title; } } However, I often get the following error message. 'x' is not a valid value for property 'Name'. Where x seems to be almost anything, drilling down into the exception details doesn't seem to provide any useful information (e.g. the InnerException is null.) Does anyone know what is happening here? 回答1: The

WPF - FrameworkElement - Enumerate all decendents?

你。 提交于 2019-12-24 01:58:13
问题 I have a FrameworkElement (really a ToggleButton ) that has inside its content a Popup . I access it like this: ToggleButton button = (ToggleButton)sender; Popup popup = (Popup)button.FindName("popSelectIteration"); Usually this works fine. But sometimes popup is null. I am trying to find a way to debug this. Is there a way enumerate all the "things" that FindName could find? As background, here is how my popup is defined in the ToggleButton: <ToggleButton Grid.Column="1" HorizontalAlignment=

FrameworkElement.Parent and VisualtreeHelper.GetParent behaves differently

巧了我就是萌 提交于 2019-12-20 02:29:54
问题 In a WP7 app, I used FrameworkElement.Parent recursively to determine whether a specific element is inside of another element. But it does not always work correctly. Then I changed my code to use VisualtreeHelper.GetParent method recursively, and it always work correctly(so far as I tested). So what is the difference of them? Thanks 回答1: Consider ControlA and ControlB where ControlA is a content control meaning it can contain other controls. <ControlA> <ControlB /> </ControlA> Logically the

FrameworkElement`s DataContext Property does NOT inherit down the element tree

跟風遠走 提交于 2019-12-17 19:48:47
问题 Hello WPF Pros at least I hope some of you read this! DataContext is a property on FrameworkElement (base class for all WPF Controls) and is implemented as a DependencyProperty. That means all the descendant elements in the logical tree share the same DataContext. So the ContentControl should do it with its descendant elements right? I have a scenario where that is NOT the case and I would like to know WHAT is the cause of that misbehaviour ?! That you understand a bit more about it please