attachedbehaviors

SL4/MVVM: Handle MouseDragElementBehavior.Dragging event with void Foo() in VM

醉酒当歌 提交于 2019-11-29 15:15:24
I am trying to handle the MouseDragElementBehavior.Dragging event on a control I have. See here for background on why I want to do this. I am having trouble wiring up this event. From the XAML you can see I have added a behavior to the user control. Then I attempted to add a handler to the Dragging event on the behavior via the CallMethodAction EventTrigger. <i:Interaction.Behaviors> <ei:MouseDragElementBehavior ConstrainToParentBounds="True"> <i:Interaction.Triggers> <i:EventTrigger EventName="Dragging"> <ei:CallMethodAction MethodName="NotifyChildrenYouAreDragging" TargetObject="{Binding}"/>

How can I fix the DependencyPropertyDescriptor AddValueChanged Memory Leak on AttachedBehavior?

烈酒焚心 提交于 2019-11-29 04:06:40
I know I need to call RemoveValueChanged, but I have not been able to find a reliable place to call this. I'm learning that there probably isn't one. I looks like I need to find a different way to monitor the change then adding a handler using AddValueChanged. I'm looking for advice on the best way to achieve this. I've seen the recommendation of using a PropertyChangedCallback in the PropertyMetadata, but I'm not sure how to do this when my TextBox and Adorner are not static. Also, the IsFocused property is not a DependencyProperty created in my class. Thanks. public sealed class

How do you handle a ComboBox SelectionChanged in MVVM?

混江龙づ霸主 提交于 2019-11-28 17:29:28
For those doing pure MVVM, how do you handle a ComboBox SelectionChanged event without reverting to code behind? I tried e.g. AttachedBehaviors but Event="SelectedChanged" is not supported: <ComboBox> <ComboBoxItem Content="Test1"> <c:CommandBehaviorCollection.Behaviors> <c:BehaviorBinding Event="SelectionChanged" Command="{Binding SelectedChanged}" CommandParameter="MainBorder123"/> </c:CommandBehaviorCollection.Behaviors> </ComboBoxItem> <ComboBoxItem Content="Test2"/> <ComboBoxItem Content="Test3"/> </ComboBox> You would use a data trigger to trigger an event on a different UI element such

When should I use FrameworkPropertyMetadata or UIPropertyMetadata over plain PropertyMetadata?

我们两清 提交于 2019-11-28 15:15:34
问题 When looking at sample attached properties and behaviors, I've seen a mishmash of uses of FrameworkPropertyMetadata , UIPropertyMetadata and PropertyMetadata . Since they all form an inheritance hierarchy, how do I choose which one to use? 回答1: These classes are to report some behavior aspects of a dependency property. Check the different classes for the options they provide. For example, if you just want to back a property by dp and provide a default value, use PropertyMetadata , if you want

How can I fix the DependencyPropertyDescriptor AddValueChanged Memory Leak on AttachedBehavior?

ε祈祈猫儿з 提交于 2019-11-27 18:17:21
问题 I know I need to call RemoveValueChanged, but I have not been able to find a reliable place to call this. I'm learning that there probably isn't one. I looks like I need to find a different way to monitor the change then adding a handler using AddValueChanged. I'm looking for advice on the best way to achieve this. I've seen the recommendation of using a PropertyChangedCallback in the PropertyMetadata, but I'm not sure how to do this when my TextBox and Adorner are not static. Also, the

How do you handle a ComboBox SelectionChanged in MVVM?

♀尐吖头ヾ 提交于 2019-11-27 10:31:09
问题 For those doing pure MVVM, how do you handle a ComboBox SelectionChanged event without reverting to code behind? I tried e.g. AttachedBehaviors but Event="SelectedChanged" is not supported: <ComboBox> <ComboBoxItem Content="Test1"> <c:CommandBehaviorCollection.Behaviors> <c:BehaviorBinding Event="SelectionChanged" Command="{Binding SelectedChanged}" CommandParameter="MainBorder123"/> </c:CommandBehaviorCollection.Behaviors> </ComboBoxItem> <ComboBoxItem Content="Test2"/> <ComboBoxItem Content