WPF ViewModel get noticed on View Visibility part 2

Tuesday, January 6, 2015

I was presented a nice trick and solution for case we like the ViewModel get noticed on View :Loaded , I am talking about this one .I just forget to show the behavior way to deal with it which is definitely an elegant solution :You can add simple Behavior like this public class ViewVisibilityObserverBehavior : Behavior<Window> { protected override void OnAttached() { AssociatedObject.DataContextChanged += AssociatedObject_DataContextChanged;   AssociatedObject.Loaded += AssociatedObject_Loaded;   AssociatedObject.IsVisibleChanged += AssociatedObject_IsVisibleChanged;   base.OnAttached(); }   void...
אין תגובות

Text Input validation via Behavior with regular expression

Wednesday, December 10, 2014

,If you need a validation to a textbox input values Use behavior like the next one , and don't mess your code with codeBehaind sections, also it is !the best for reuse of code The following demo-code is for windows standard file name rules, you can easily change the .Regular expression as you need public class FileNameValidation : Behavior<TextBox> { private string regex = @"^+$"; protected override void OnAttached() { ...
אין תגובות

WPF Behavior real demo Part 2

Monday, March 31, 2014

.In this demo we demonstrate a Contextmenu Control and its DataContext Property attached ,Context-menu itself is quit problematic control with allot of connectivity troubles I am not gonna digging here on it, but you can read a small demo in my previous Post In Shortly, it is kind of problem to manage the Contextmenu DataContext and especially by the right way, I have saw a few solutions around the Web but unfortunately I cant support those .suggestions, and I think that many of them isn’t tested before This behavior will attached to any control you gave a Contextmenu, and its purpose is quite ,simple, to...
תגיות: , ,
אין תגובות

Customize WPF Contextmenu using MVVM

Friday, March 28, 2014

,Context Menu is if To say the least not so user friendly Well, the problem I will present here its because a special case in my application, but also could be relevant for customize ContextMenu or Control on its creation time or handle it in variety of .cases To be concrete we are hosting an 3 party Control and it is of Winform type, well all of it non so relevant except the point that is kind of blowing the UI Event Handled like KeyDown mouseEnter etc. well, after we hosting this control I where needed to add it some contextMenu...
תגיות: , , ,
תגובה אחת

WPF Behavior – Real Demo Part 1

Friday, February 28, 2014

As we sow in my Behavior intro post LINK .its very simple, now lets develop some real demo I choose for Numbers Only TextBox. .There are a few ways for implementation but I think it is one of the best :Lets following this code public class NumbersOnlyBehaviors : Behavior<TextBoxBase> { protected override void OnAttached() { AssociatedObject.PreviewKeyDown += AssociatedObject_PreviewKeyDown; base.OnAttached(); ...
תגיות: , ,
אין תגובות

WPF Behavior – Introduction

Thursday, February 27, 2014

Behaviors in WPF its Part that we cannot allow ourselves to missThis is Extra Easy to use and very powerfulAlmost any UI requirements can fully implemented with BehaviorsSome times even on taking place of good Programing methodAnd since Behaviors can be implemented thru Blend ,UI Designers could use them tooYou don’t heard that from me , be careful with your designers permissionsSo, back to the ConceptAdd to your solution reference to: interactivity dllYou can find it in every windows projectWe gonna use it twice, on your C# and in the XAML codeNow , create new class which inherit from...
תגיות: , ,
תגובה אחת