I recommend to check the Output Window in visual studio and see if any Binding is failing.
I recommend to check the Output Window in visual studio and see if any Binding is failing. Are you sure when you select something, the selection updates into the SelectedUser property? Did you put a breakpoint in setter of SelectedUser and see that it is hitting when you select something on the datagrid?
The reasons for this Binding to break could be many ... SelectedUser is of different type than individual Users. SelectedUser does not match by reference with any items in Users. How and where are you setting null?
The following code in my case works perfectly fine... When I set MyDGSampleWindow. MySelItem as null, the datagrid propertly deselects. Perhaps you might need to give us more input on how are you actually setting the value as null.
You are right, I was not setting the property to null as I should have. I was creating a new object instead of setting it to null. Solved it by first setting the property to null and then giving it a new object.
Thank you! – Florin Bombeanu Oct 20 at 9:38.
Yeah may need to add the XAML UpdateSourceTrigger to update the UI. SelectedItem="{Binding SomeProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}.
This doesn't solve the problem, sorry. – Florin Bombeanu Oct 20 at 9:22.
AFAIK, this will allow you to unselect it by setting the SelectedUser to null. I cannot test it at the moment, but you could also try to add this in the setter of your property: set { selectedUser = value; OnPropertyChanged("SelectedUser"); ICollectionView collectionView = CollectionViewSource. GetDefaultView(Users); collectionView.
MoveCurrentTo(selectedUser); } (For ICollectionView to do anything, you will need to have IsSynchronizedWithCurrentItem set) Like I said, I cannot test this right now. Also, the setter of the property is probably not the best place to put it. Maybe create an event handler for the PropertyChangedevent locally and put that logic there.
Let me know if it helps, else I'll see if I can run a short test...
The DataGrid will not Deselect it automatically as DataGridRow's IsSelected property should be set to False. You can do that by Setting a style on DataGrid.. like The IsSelected property should be the of the object i. E in your case RPLUser should have a property Isselected Then before you set the SelectedUser to null... just do SelectedUser.
IsSelected=False And don't forget to attach this style to the DataGridRowStyle in Datagrid I am using WPFToolkit you can modify the style if you are targetting . NET 4.0.
You can remove the BasedOn BasedOn="{StaticResource {x:Type WPFToolkit:DataGridRow}}" – adcool2007 Oct 20 at 9:30 This doesn't look to be an issue of datagrid row's not getting deselected. I just checked it, and in basic setup the datagrid deselects when selected item is set to null via Binding. – AngelWPF Oct 20 at 9:36 @AngelWPF I tried to do it tat way but it was not working so I tried it the Style way – adcool2007 Oct 20 at 9:38.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.