UWP Binding vs. X:Bind part B

Wednesday, December 13, 2017

x:Bind with methods & events Back to the start, Xbind allow us to directly binding Events to Functions which is awesome, it just downgrade the Command pattern , Binding of course just can’t . there is no restriction about binding to method, you can bind with arguments, to return value etc. & of course the default EventHandler signature with default parameter or without. For example: <VariableSizedWrapGrid>    <Button Content="click to void method" Click="{x:Bind Foo, Mode=OneWay}" />    <Button Content="double method with args" Width="{x:Bind Foo2(100),Mode=OneWay}"/>    <Button Content="sting method" ToolTipService.ToolTip="{x:Bind Foo3(),Mode=OneWay}" />    <Button Content="Event pointer enterd method" PointerEntered="{x:Bind Foo4}" /> </VariableSizedWrapGrid> private void Foo() { } ...
אין תגובות

Prism 6 from ground up by 10 minutes

Sunday, April 3, 2016

In this post we will build a small app using Prism 6 and Unity together with all necessary  tools. One of the commonly known issues  with Prism is the different between versions and dlls. So I choose in the demo to use the last nugget package and to trust it. Than to manipulate all around it, Well surprising way, installing unity for Prism 6 was include automatically all Prism 6 dependencies which reduce any computability  issues Well, Prism architecture is simple, A. We have Shell which is the main window and probably the only window in the application. B. We have Regions inside the Shel and they would...

MVVM View first VS. ViewModel first

Monday, January 25, 2016

Since early times UI developers has merchandise with the purpose of MVVM It is hard to judge what is better way to develop with,  in this post I will try to demonstrate they both,  and compare a little but definitely not to have a statement of what is right, -  The term of ViewModel evolution 1: Is it a Model translation for presentation layer, So when we writing this ViewModel class we actually relay either on a real model like  a physical entity or virtual one like other class  -  The term of ViewModel evolution 2: In MVVM CodeBehind is prohibited, there for every reaction for...
אין תגובות

Cancel Selcted Event but invoke the Command

Tuesday, November 10, 2015

The challenge  here is relevant for several scenarios, like validation , hooking, etc. when pressing on a button we can invoke the bind command but ignore the selection event, while doing it in a attach property like this one we can keep the MVVM pattern clean . the command is actually get fired ,but the button stays calm. It is also usable in every other control who let us fire the command on mouse enter like in interactions-trigger but block the other items in the chain. public static class CancelClickAction { public static readonly DependencyProperty OnClickProperty =...
אין תגובות

Xaml – Validation – IdataErrorInfo with RegX

Monday, August 10, 2015

WPF provide the well-known Validation mechanism, its colored with red border the under-validation-control.        I have been recently asked few times how to use it, so here is the simple and shortest demo you might find. At the ViewModel: Implement IDataErrorInfo interface from ComponentModel , Its provide a indexer which get called only if you defined validation connection on Xaml. public class viewModelDemo : IDataErrorInfo { public string Error { get { throw new NotImplementedException(); } ...
אין תגובות

AutomationID in CustomControl based string format

Wednesday, June 3, 2015

This common question coming up from time to time in a variety of variations, Today when automation testing is a standard , and we have a resource control in a custom library or in userControl library which use in several cases and by different locations in the same App. Well, if you writing a pay per use control of course you need a professional solution like exposing a dependency property per unit But for a quick solution or adding solution for third party control without the necessary supports you can try this one, as an example have a look on BlogPost i have been...
אין תגובות

ADV. XAML programing part 1 – Tag Element for Binding tricks

Tuesday, March 17, 2015

.Really a powerful and cool feature ..You have a native control, like button, textElement, dataGrid etc Now you like to implement something like decorator pattern to use on the control. You can "Tag" your ..control Meaning, use the property Tag to extend your control and than stick on it an additional properties .from other class Meaning , every Xaml Object has a Datacontext Property, which can be used for DataBinding , we can also trying to invoke things by relative binding technics, but sometimes its not enough, so Tag .property could be a fantastic solution ,The Tag property is part of FrameworkElement class and is from type...
תגובה אחת

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 Bind Collection based on ToStinrg might demolish your Binding

Tuesday, November 18, 2014

few days ago I was in a middle of WPF-MVVM workshop and I built a live demo with some Object who implement INotifyPropertyChanged interface and based on ObservableCollection to the .Listbox .this is very basic demo to show the power of the technology In this point my object Model was shows on the UI as “NameSpace.ClassName” so I just were ..decide to override the toString on it to see the Object details and all was just great ..The Problem The next level was to open the selected item in EditBox there we can try to change the item data .and see the changes on the main...
תגובה אחת

Views Locator or Navigation Service for MVVM

Wednesday, November 12, 2014

Many frameworks of MVVM provide Views Service Locator , which allow you to inject any view in .any place without reference or dependencies between libraries .Actually , it is not very hard to write one of your own if needed :For example lets try that :Base contract fro the service public interface IAppNavigationService { object ResolveView(string key); void SignView(string key, Type viewType); List<string> getAllKeys(); } :A simple version of implementation public class AppNavigationService : IAppNavigationService { ...