WPF Databinding- Not your fathers databinding Part 1-3

As Promised here is my advanced databinding presentation from South Florida Code camp and also Orlando Code camp. you can find the demo files here.

Here is a quick description of the first demos, there will be 2 other Blogposting in the next few days getting into more advance databinding topics.

  • Example00

  • Here we have 3 textboxes,

  • The first textbox mySourceElement

  • Second textbox has a binding to mySourceElement and Path= Text

<Binding ElementName="mySourceElement" Path="Text"  />

  • Third textbox is also bound to the Text property but we use inline Binding

Here is the entire XAML

    <Grid  >           <Grid.RowDefinitions >                                             </Grid.RowDefinitions>         <TextBox Name="mySourceElement" Grid.Row="0"                  TextChanged="mySourceElement_TextChanged">Hello Orlnado                                 <TextBlock.Text>                 <Binding ElementName="mySourceElement" Path="Text"  />             </TextBlock.Text>                    

  • Example01

  • we have a slider control, then we have two textboxes bound to the value property of the slider. one has its text property bound, the second has its fontsize property bound.

                                                   
  • Example02

  • very much like the previous example but it also has a font dropdown

                                                                                                          
  • Example03

  • In this example we bind to an object Employee.cs

  • Notice we added a directive to our xaml which is clr-namespace and the namespace for our employee Class

xmlns:local="clr-namespace:Example03"

  • In Our windows Resources we create an instance of our object

<Window.Resources>     <local:Employee x:Key="MyEmployee" EmployeeNumber="145"                     FirstName="John"                     LastName="Doe"                     Department="Product Development"                     Title="QA Manager" />

</Window.Resources>

  • then we bind our container to the that instance of the data
                                                                                                                   

   

  • and Finally we have textboxes that will bind to that textbox          Employee Number                 First Name                 Last Name                 Title                 Department        
This article is part of the GWB Archives. Original Author: Shervin Shakibi

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.