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...
אין תגובות

WPF string is null or empty using Xaml Trigger

Monday, October 20, 2014

:Nice to have When work on xaml and no C# available from any reason (no binding and no converter) :We can also do some tricks on UI like in this case We have a textBlok and we need to hide it when no text presented In C# we use to write if(! String.IsNullOrEmpty(string value)) :But, it can be easily done with pure Xaml with Trigger like <Style TargetType="TextBlock"> <Style.Triggers> <Trigger Property="Text" Value=""> ...
2 תגובות

Introduction to WPF Triggers Part C

Monday, January 27, 2014

    .This chapter will dealing with combine Trigger ,After the last Post about Triggers was about Data Trigger I am now on a combination of Data Trigger and other Trigger The most easy sample is with Property Trigger , if we take the previous post Demo-Code http://blogs.microsoft.co.il/uriel99/2014/01/06/introduction-to-wpf-triggers-part-b/ :and keep the Model and the ViewModel as is public class Data : INotifyPropertyChanged { public Data() { } private int Id; ...
תגיות: , , ,
אין תגובות

Introduction to WPF Triggers Part B

Monday, January 6, 2014

More complex WPF Trigger is the Data Trigger, The idea is , depends on your Object Model , when some property State or Value equal to some condition the UI reacts as your design. For a small demonstration lets look up on this code: public class Data : INotifyPropertyChanged { public Data() { } private int Id; public int PublicID ...
תגיות: , , ,
תגובה אחת

Introduction to WPF Triggers Part A

WPF Triggers provide excellent visual effects, without any codeBehind, and it's not must to be for Xaml Designers only, any wpf developers can do this. WPF Style triggers are came for well defined cases of any WPF Control and reacts for Properties and Events, in case like: CheckBox.IsChecked or Mouse Enter WPF Triggers can be separate into a few Parts. Event Triggers, Data Triggers, Property Triggers , and Multi Triggers, in the most of cases, one demand could be resolved by more than one method, as General Note Place yours triggers in a Style section and not inline style. for a start lets build...
תגיות: , , ,
אין תגובות