TemplateBinding and TemplateParent Digging

Monday, May 9, 2016

One of the things that can completely freak you out. Lets start with facts: 1.  While customize an application you might use something like this: <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MyProperty}"/> Or maybe this: <TextBlock Text="{TemplateBinding MyProperty}" /> While this is on the ResourceDictionary of your app and about to styling your custom control, and MyProperty is an DependencyProperty on the logic part of the Control so what the different between those two?  And what the default choose should be? By the way while most of programmers used to write You can use the Short way as: Text="{Binding TemplatedParent.MyProperty2}" 2.    A full demonstration will be like  this one: public class CustomControl1 : Control ...
אין תגובות

Implement Complex Binding Using MultiBindingConverter

Tuesday, August 12, 2014

To be familiar with advance Xaml Technics could be rewarding ,For example .We have an DataGrid The GataGrid located in UserControl, where every row on the grid represents an Complex Item from a collection, so when we customize the GridTemplate columns, every Cell DataContext is actually one item from the collection .for example every DataGrid Column is something like that <DataGridTemplateColumn Header="Item" > <DataGridTemplateColumn.CellTemplate> ...
אין תגובות

Nullable Boolean Parameter in UI.

Sunday, July 6, 2014

assume you dealing with IDE for some database engine, well your filtering :requirements is about "give me all above 100 dollars" "give all under 100 dollars" and ."give me all no matter the price" Now representation of this functionality in UI is one Problem, we have 3 state .checkbox, or maybe with 3 radio buttons or better will be custom 3 states control But using on of those simple Boolean controls could made a serious head problem since it cannot be bound to Nullable Boolean and hold a three boolean fields and ,sync them it is quite a mess And what do I mean ?...
אין תגובות

How represents Enum Value in Radio Button Group and bind it

Wednesday, March 19, 2014

.In many cases we have some Enum represents some values ,Now, the Gui shows a few radio Buttons for connection to those Enum values Generally we are using some Combobox for scenario like this but now assume that you are in .order to implement the UI using Radiobuttons group ,So The first way is to bind any of your Radiobuttons to a Boolean value and sync your Model with .some transform function The problem with that way that is even if it works fine and not so complicated I had some bad ,feelings about it, and not to mention case of many Enum values So second way could...
תגיות: , , , ,
אין תגובות

WPF Text Trimmer Converter

Wednesday, March 5, 2014

Sometimes our bindable collection values is a complex mix of Data or some values from database, the point is that the names are not so user friendly :Like ..M_data1 , M_data2 etc Or x432Person , x433Person , x434Person , it could also be a result of Enum Binding .As a conclusion of all of it we can show in our UI a Normalize Data in several methods ,We can use xaml Abilities like DisplayMemberPath , we can implement ToString Well those two options not always relevant, yet we can refactoring a collection in our ViewModel .to kind of String-Collection which is a copy of the real...
תגיות: , , ,
תגובה אחת

WPF Converter For Binding Debbuging

Monday, January 6, 2014

Its is well Known (by WPF Developers ) yet, it's Simple and powerful . When you need to check your Binding Syntax . if there is any reason to write it, ect. ect. I Mean its obviously the only way to check your Binding Xaml Syntax, It is very important in case of {Relative Source Bla Bla Bla} If the Convert Function getting Called you know the Binding is Actually works , and the Object Parameter can help you to understand whats arrived into the UI Object and if it is what you were expecting for it. The source code is supposed to be...
תגיות: , , , ,
אין תגובות

WPF Converter in Resource Dictionary

Tuesday, October 15, 2013

Using converter is daily, in as general we doing that like this A. Define a c# ValueConverter B. Set Xaml namespace like this xmlns:converters="clr-namespace:X.Y.Converters;assembly=X.Y" C. set local resources with key like this <UserControl.Resources> <converters:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" /> /UserControl.Resources> D.  just using the key inside your document where is needed: < MediaElement Visibility="{Binding Path=X.Visibility, Converter={StaticResource boolToVisibilityCollapsedConverter}}" /> But, inside Resource dictionary file when you need some Converter you cannot use local resource as Static Resources, so what you need is either Global static Converters allocate in your App.Xaml , or simply using the next xaml syntax A. add Xaml namespace like this xmlns:localConverters="clr-namespace:X.Resources" B. and use Binding Converter syntax ...
תגיות: , , ,
תגובה אחת