In Part 3 of this little mini-series on data binding in Windows 8 we looked at Element Binding. Today, we'll take a look at Data Conversion.
At times the data in your business object (the source for your binding) and the target UIElement may not have an exact type match. For example, if your Employee class wants to keep track of the start date for each Employee, a sensible way to do so is with a DateTime object. However, when we display that data we'll want to use a Text object, and we may not want the entire default conversion of a DateTime to a string. To rectify this problem, we can create a class that performs a conversion from one type to another (in this case, from DateTime to string). This class will implement IValueConverter and will have two methods: Convert, and ConvertBack.
Read More from: Original Source
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
C#,.NET,Visual Studio,Window Phone Tutorials,Windows 8,WP7,WP8,WPF,XAML,Data Binding,Data Conversion
At times the data in your business object (the source for your binding) and the target UIElement may not have an exact type match. For example, if your Employee class wants to keep track of the start date for each Employee, a sensible way to do so is with a DateTime object. However, when we display that data we'll want to use a Text object, and we may not want the entire default conversion of a DateTime to a string. To rectify this problem, we can create a class that performs a conversion from one type to another (in this case, from DateTime to string). This class will implement IValueConverter and will have two methods: Convert, and ConvertBack.
Read More from: Original Source
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
No comments:
Post a Comment