1 / 10

Input And Data Binding in WPF Development

Windows Presentation Foundation (WPF) provides a powerful API with the help of which applications can get input from various devices such as mouse, keyboard, and touch panels. Data binding is the process that establishes a connection between the application UI and business logic.

Download Presentation

Input And Data Binding in WPF Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Input And Data Binding iFour Consultancy https://www.ifourtechnolab.com/wpf-software-development

  2. Input And Data Binding • Windows Presentation Foundation (WPF) provides a powerful API with the help of which applications can get input from various devices such as mouse, keyboard, and touch panels. • Data binding is the process that establishes a connection between the application UI and business logic. If the binding has the correct settings and the data provides the proper notifications, then, when the data changes its value, the elements that are bound to the data reflect changes automatically https://www.ifourtechnolab.com/wpf-software-development

  3. What We Will Cover • Binding data to UI Elements • Using Converters to convert data during Binding • Using Data Templates to visualize data https://www.ifourtechnolab.com/wpf-software-development

  4. Data Binding Concepts • Binding Components • Target Object • Target Property • Binding Source • Path • Target Property Must be a dependency property https://www.ifourtechnolab.com/wpf-software-development

  5. Binding Modes • OneWay-Updates the target property only when the source property change. • TwoWay-Updates the target property or the property whenever either the target property or the source property changes. • OneWayToSource-updates the source property when the target property changes • OneTime- Updates the target property only when the application starts or when the DataContext undergoes a change. https://www.ifourtechnolab.com/wpf-software-development

  6. What Triggers Updates • Triggering supported by TwoWay or OneWayToSource mode of binding • Dependency property or INotifyPropertyChanged • UpdateSourceTrigger property • Explicit -Updates the binding source only when you call. • UpdateSource- method.  • LostFocus-Updates the binding source whenever the binding target element loses https://www.ifourtechnolab.com/wpf-software-development

  7. Data Binding Methods • Binding using XAML • Binding using Code <Label Name="lblNote" Content="{DynamicResource ResourceKey=Note}" /> <TextBox Name="txtNote" VerticalContentAlignment="Top" HorizontalAlignment="Stretch" Text="{Binding AppointmentNote,Mode=TwoWay}" VerticalAlignment="Stretch" Width="Auto" Height="Auto" /> MyData myDataObject = new MyData(DateTime.Now); Binding myBinding = new Binding("MyDataProperty"); myBinding.Source = myDataObject; myText.SetBinding(TextBlock.TextProperty, myBinding); https://www.ifourtechnolab.com/wpf-software-development

  8. Converting DataOverview • Used when data doesn’t match between bindings create a conversion class • When to use • Culture changes needed • Different View of data then native storage • Incompatible data types between target and source https://www.ifourtechnolab.com/wpf-software-development

  9. Converting DataOut-of-Box Converters • Contained in the System.Windows.Controls namespace • BooleanToVisibilityConverter • Converts True/False to Visible, Hidden or Collapsed • BorderGapMaskConverter • Represents a converter that converts the dimensions of a GroupBox control into a VisualBrush https://www.ifourtechnolab.com/wpf-software-development

  10. Data Templates Overview • Makes it easy to put content with data • Easy to define visual styles for data • Reusable and modifiable https://www.ifourtechnolab.com/wpf-software-development

More Related