Skip to main content

Posts

Showing posts with the label DataBinding

UpdateSourceTrigger in WPF

This is a property on a binding that controls the data flow from target to the source and used in two-way databinding scenarios. The default mode is when focus changes but there are number of other options available, which we will see in this article. Data trigger scenarios: Let’s talk about some of the data trigger scenarios.  By default, modified values in the binding controls only get pushed down when we do activity related to focus change like tab out, minimizing and maximizing window, etc. ·     In some scenarios we want to update values as quickly as possible, or let’s say with every key stoke.  So, to achieve such kind of scenarios Microsoft provided  UpdateSourceTrigger .  Properties available with  UpdateSourceTrigger : Default – This is the default value and it means a lost focus for most of the controls LostFocus – Value updation will be on hold until the focus moves out of control PropertyChanged – Value updation will happen whenever a target property

Troubleshooting data binding

We all know that DataBinding is one of the most powerful concept of WPF. So, today I thought to write something on how to troubleshoot data binding related issues while working with any XAML based application. Here I'll not talk about what and how data binding works, instead I'll jump directly on the relevant part. So, let's start by picking up the troubleshooting methods which can make developer's work bit easy. Way 1: Using Visual Studio output window Visual Studio provides high level information about binding which is sufficient to resolve very small problems like name mismatch, etc. Let's understand this along with a code snippet: <Grid> <TextBlock Text= " {Binding ElementName=label, Path=Hello, Mode=OneWay}" /> <Label Content= " Welcome" Name= " label" /> </Grid> Now open your output window and press F5, application will launch. In output window, you will notice that the message

Safest way to use RaisePropertyChanged method - MVVM series 3 of n

Background In my previous post on  Simplest MVVM Ever , I gave the simplest overview of implementing MVVM. Now moving forward, I thought to extend my previous post by picking individual areas. And this time, I selected  RaisePropertyChanged . All the developers working on XAML related apps are very well aware about the use of this RaisePropertyChanged. I am sure, most of us are also aware on where to use this. But does everyone aware about what is the proper way or let's say generic way to use it ??? Well, even if you are not aware, no problem. At the end of this post, you will surely take home a useful tip on using  RaisePropertyChanged . Introduction As we know that MVVM provides a loose coupling methodology. At lot many places it is very useful to get benefit of such architecture, but at the cost of your alertness. Because when we are talking about MVVM, we usually says that ViewModel has no knowledge about View and properties are the way, who binds View and ViewModel to