(..Custom Control – part 13 (the templating way

31 בDecember 2014

Well , sometimes , to customize Control we can use an other control with the look and fill of.original oneFor this example I gonna use TabControl as Expander.We all familiar with expander as a Control it is an old structure for desktop apps?First why a TabControlSince TabControl already build as a header and content structure tilt the TabControl for us.might be easyThe main guidelines will be: place an toggle-Button in TabControl Header which control on:TabContent visibility:First draw a style for ToggleButton<Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}"> <Setter Property="Template"> ...
אין תגובות

Few rules about how to decorate an Items Control in WPF

18 בDecember 2014

.The first is Data Template The old good one, the basic tool when we are trying to draw an Data Element in our flavor and I have a long guide about it here :In shortly <!--DataTemplate--> <DataTemplate x:Key="localTemplate1"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Id}" /> <TextBlock Text=" - "/> ...
אין תגובות

Text Input validation via Behavior with regular expression

10 בDecember 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 Window Loaded and ContentRendered Events

2 בDecember 2014

Very important to be familiar with this concept, As in many other scenarios WPF provide a subset of prevents and ongoing Events and allow us .to registered for different application lifecycle events The most known events are key-down and preview-key-down :Now for details public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; ContentRendered += MainWindow_ContentRendered; } We can register to...
אין תגובות