Understanding Windows Presentation Foundation Data Binding
Presentation Foundation helps you to create rich user interfaces for your application.
In order to create such rich user interfaces XAML, the XML based markup language
has been developed by Microsoft. This has a rich data binding model too. Data
binding is an important part in any application.
For selecting a framework, the main point considered is how easily we could accomplish these tasks.
· One method is to create control, which doesn't know anything about data portion and set the values programmatically whenever controls are loaded.
· Another method is to define controls and data source and bind them using binding property. Here framework decides how to set the control's content property.
The second approach is more efficient way of doing things especially when the program involves large amount of data manipulation.
The following sample code shows how a data for the control can be set using the first method using XAML and C#.
The above code is for layout of controls in the window to display data.
myBlog = new XmlDocument();
Window1_Loaded(object sender, RoutedEventArgs e)
XmlNodeList nodes = myBlog.SelectNodes("//item");
blogListBox_Changed(object sender, RoutedEventArgs e)
The above code is for populating the controls with data, when appropriate event occurs.
Approach 2: Using DataBinding features of WFP.
<XmlDataProvider x:Key="RssFeed" Source="c:\ test.RSS" />
The above code in XAML accomplishes the task simply by marking some declarative statements.
we can bind different objects using the Binding object.
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________
to our mailing list and receive new articles
: We never rent, trade, or sell my email lists to
Visit .NET Programming Tutorial Homepage
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.
Copyright - © 2004 - 2023 - All Rights Reserved.