Download presentation
Presentation is loading. Please wait.
Published byShawn Stone Modified over 9 years ago
1
WPF Data Binding Tomer Shamam Smart Client Team Leader Sela Group tomer@sela.co.il http://blogs.microsoft.co.il/blogs/tomershamam
2
Agenda WPF in a Nutshell Today’s Data-View Data Binding Concept Handling Data Changes Value Conversion Collection Data Binding Data Validation Trace and Debug Data Visualization New in.NET 3.5 SP1 Limitations
3
WPF in a Nutshell
4
Today’s Data-View Set Move Load
5
Data Binding in Action One Way Two Way One Time One WayTo Source
6
Data Binding in Action
7
Handling Data Changes Socket socket = …; View view = …; Binding binding = …;... socket.IsActive = true; Socket socket = …; View view = …; Binding binding = …;... socket.IsActive = true; IsActive = Socket false Changed true
8
Property Change Mechanisms INotifyPropertyChanged interface Changed event pattern PropertyDescriptor value changed WPF DependencyProperty
9
Handling Data Changes
10
+ Temperature Site INotifyPropertyChanged Two-way Value Conversion Temperature Brush Converter Temperature Brush Converter Fahrenheit Celsius Converter Fahrenheit Celsius Converter
11
Data Binding Converters
12
Collection Data Binding Collection SingleSocket <ListView ItemsSource=“{Binding}” /> ItemsSource=“{Binding}” /><ListView Sort () Filter() Group() Sort () Filter() Group() CollectionView OnOffSwitch RangeSwitch SingleSocket
13
Collection Binding
14
Data Validation User input validation in WPF is done through Binding Three options to validate input: ExceptionValidationRule IDataErrorInfo Custom Validation Rule <Binding Source="{StaticResource data}" Path="Age" UpdateSourceTrigger="PropertyChanged">
15
Validating User input
16
Trace and Debug Binding throws exceptions on critical errors Path spelling mistakes are traced Binding errors are traceable TraceListener listener = new XxxWriterTraceListener(...); PresentationTraceSources.DataBindingSource.Listeners.Add( listener);... C# App.config
17
Data Binding Tracing
18
Data Visualization Collection SingleSocket OnOffSwitch RangeSwitch SingleSocket
19
Data Visualization
20
Limitations Data Binding is Untyped Target is limited to DependencyObject No multithreaded support for Collection Binding Data Template parts are Hard to Get! Interface-specific Data Template is not supported Blend data-binding support is limited
21
New in.NET 3.5 SP1 StringFormat support within {{ Binding }} expressions New alternating rows support in ItemsControl Better handling for null in editable controls Item-level validation MultiSelector support IEditableCollectionView support Performance improvements with IEnumerable
22
Summary New Design Approach Data-View Decoupling Better Development Experience Eliminates Boilerplate Code Try it now…
23
Resources Data Binding on MSDN http://msdn2.microsoft.com/en- us/library/ms750612.aspx http://msdn2.microsoft.com/en- us/library/ms750612.aspx Windows Client.NET http://windowsclient.net/ Beatriz Costa Blog http://www.beacosta.com/blog/ http://www.beacosta.com/blog/ My Blog http://blogs.microsoft.co.il/blogs/tomer shamam/ http://blogs.microsoft.co.il/blogs/tomer shamam/
25
© 2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.