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

Customize Window header Style

Thursday, March 10, 2016

In case you demand some extras from your MainWindow as programs like Microsoft Office did, Lets say extra icons, menus , buttons or whatever. The built in Window of System.Window type and its API in Xaml is very uncomfortable for customization and guess what , you the one who need to do all the dirty work. All of it? well I gonna help you to how to start. In this screen shot I have, 1 . Icon on left (standard) 2. App name at left (standard) 3.  details on center (extra) 4. app special menu at right (extra) 5. window buttons at left (kind of standard) So, first...
אין תגובות

WPF Custom Controls – toggle buttons with Group

Sunday, October 4, 2015

The idea is quite simple , create header of ListBox who combine two types of contents, to be acting like an tab control , meaning filtering the Listbox content, and So , for implementation we can considerate a few options, Tabcontrol , RadioButtons , Toggle Button etc.. Just for the fun I have made it with toggles, the truth is I where must use them because of look an fill demands and styling but this is not the point, The point is what between RadioButton control and ToggleButton control, the main issue is the group who might surround the radio buttons and auto switch...
אין תגובות

ADV. Xaml Programing part 2 – binding to Methods

Thursday, July 2, 2015

Usually binding has been designed for properties, But there is exceptional cases of course, generally not because of yours architecture but because others, The point is that is possible, Let’s start with ObjectDataProvider . it is an old trick to represents data in xaml endpoint, And make the things shorter, In this case we just define a Xaml reference to the class who hold the desired function For Example : public static class HelperBinding { public static string Test() { ...

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

Custom Control – Xaml CheckBox to On-Off button

Tuesday, April 21, 2015

.Like the toggle or the checkbox but with much more style ,To reach this look and feel we only need a few lines of Xaml style CheckBox is one of the things that it almost impossible for styling, for example try taking control on a checkbox color.. so, what we have left is to redraw the default template of a checkbox, and it quite ,simple to be honest :So starting with simple control template <Style TargetType="{x:Type CheckBox}"> <Setter Property="Margin" Value="1,0,1,0"/> <Setter Property="Height"...
2 תגובות

Zoom Image Control-Part 2

Monday, February 23, 2015

Now lets try to develop something  more professional, meaning in Control oriented way. So it will be something like this: First describe the Control main Logic, have a Content Prop where the user can bind its Object to .zoom it, have an internal Slider which measuring and rendering this content :So use this class public class SimpleZoomControl : ContentControl { static SimpleZoomControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(SimpleZoomControl), new FrameworkPropertyMetadata(typeof(SimpleZoomControl))); } public UIElement ZoomContent ...
אין תגובות

Zoom Image Control Part 1

Friday, February 13, 2015

I had to provide my client images zoom control . I decided to take advantage of the opportunity and to share with you the development path. Round tiresome in the network brought me a number of examples , some of which were not accurate at all and some with crazy code snippets included . So as is usually found it is more convenient for me to write from scratch and simplify matters .than embed code alien and confused This is to remind that the development environment Win8 (Win -RT ), including the type of .Control that but not Windows 7 or less .We should first...
אין תגובות

DataGrid Seperations between Column and Rows

Thursday, January 29, 2015

,The best practices .Basically this is job for a Xaml Designers. But you can do so by your own simply Both of my suggestion are based on missing property of WPF itself, something like ..HorizontalSeperationRatio and VerticalSeperationRatio .So we will be must add it by our self , using some nice trick Like everything else DataGrid has templates, to be specific DataGris is built from Columns, Rows, Cells. But only Cells and Rows provide Templates, what left us with templating for Rows and .Cells .Inside every Template usually has the Core, and that probably some kind of ContentPresnter .What we need is to surround it with proper...
אין תגובות