TwoWay Binding IsChecked on a checkbox not working

10 posts, 0 answers
  1. Mike Gold
    Mike Gold avatar
    16 posts
    Member since:
    Oct 2009

    Posted 15 Mar 2010 Link to this post

    Hi Telerik,

    I'm using the Q4 release and wondering if this was fixed or perhaps I'm doing something wrong.  If I create a GridViewDataColumn with a checkbox in a cell template,  the two way binding doesn't work coming back from my viewmodel properly.  It notifies the grid I think, but you need to scroll or page back and forth to see the update of the checkbox.   In other words, if I set IsSelected to true in my view model, it doesn't get reflected in the grid unless I scroll up and down or page back and forth.  Then I see the refresh properly.

    To better understand the issue

    Here is my XAML:

     

     

     

            <telerik:RadGridView Grid.Row="1" x:Name="SearchResultsGrid" ItemsSource="{Binding SearchResults}"  FrozenColumnCount="2" AutoGenerateColumns="False"   
                                 HeaderRowStyle="{StaticResource SearchHeaderRowStyle}"   
                                 RowStyle="{StaticResource SearchNormalRowStyle}"   
                                 AlternateRowStyle="{StaticResource SearchAlternatingRowStyle}"   
                                 AlternationCount="2"   
                                 RowIndicatorVisibility="Collapsed" 
                                 MultipleSelect="True" SelectionChanged="OnRowSelected" 
                                                              ><!--Background="{StaticResource GridViewRowNormalBackground}"--> 
                <telerik:RadGridView.SortDescriptors> 
                    <telerikData:SortDescriptor Member="Schema.Name" 
                                       SortDirection="Ascending" /> 
                </telerik:RadGridView.SortDescriptors> 
     
                <telerik:RadGridView.Columns> 
                    <telerik:GridViewDataColumn x:Name="CheckBoxColumn" Header="+"  DataMemberBinding="{Binding}" IsReadOnly="True" > 
                        <telerik:GridViewDataColumn.CellTemplate> 
                            <DataTemplate> 
                                <Border BorderThickness="1" BorderBrush="Gray"  DataContext="{Binding}" > 
                                    <CheckBox Style="{StaticResource CheckBox.Standard}" IsChecked="{Binding IsSelected, Mode=TwoWay}" /> 
                                 </Border> 
                            </DataTemplate>          
                        </telerik:GridViewDataColumn.CellTemplate> 
                    </telerik:GridViewDataColumn> 
     



    Here is my view model

     

            private bool isSelected;  
     
            public bool IsSelected  
            {  
                get { return isSelected; }  
                set { isSelected = value;  
     
                    PropertyChanged.Raise(this, "IsSelected");  
     
                }  
            }  
     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Mar 2010 Link to this post

    Hello Mike,

    We don't have Q4 release for more than three years - can you post the exact version of the grid assembly?

    Best wishes,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Mike Gold
    Mike Gold avatar
    16 posts
    Member since:
    Oct 2009

    Posted 16 Mar 2010 Link to this post

    Thanks Vlad,

    The Telerik.Windows.Controls.GridView.dll is showing up as

    Product Version 2009.3.1127.1030,    Copyright 2008, size 802K 

    Best Regards,

    -Mike
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Mar 2010 Link to this post

    Hello Mike,

    This version is internal build of Q3 2009 - please try our latest service pack Q3 SP2 (2009.3.1314.1030), our latest build, or even our Q1 2010.

    Regards,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 15 Apr 2010 Link to this post

    Hi,
    Is this confirmed as fixed in Q1 2010 ?

    I'm using Q1 2010 but the following code still doesn't work. (isChange is a boolean and is updated trough TwoWay, but the checkbox doesn't get checked)

     <telerikGridView:GridViewDataColumn Header="Change Data" DataMemberBinding="{Binding isChange, Mode=TwoWay}">  
    </telerikGridView:GridViewDataColumn> 

    Regards,
    Nicolas
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 Apr 2010 Link to this post

    Hello Nicolas,

    Can you verify if your objects implements properly INotifyPropertyChanged?

    Greetings,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 15 Apr 2010 Link to this post

    Yes,
    The object implements INotifyPropertyChanged

     bool _isChange;  
            public bool isChange  
            {  
                get  
                {  
                    return _isChange;  
                }  
                set  
                {  
                    _isChange = value;  
                    OnPropertyChanged("isChange");  
                }  
            }  
     
              
              
     
            #region INotifyPropertyChanged Members  
     
            private void OnPropertyChanged(string propertyName)  
            {  
                if (PropertyChanged != null)  
                {  
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));  
                }  
            }  
     
            public event PropertyChangedEventHandler PropertyChanged;  
     
            #endregion 

    If I debug, I can cleary see that the boolean is changed. However it is not reflected on the checkbox in the column.
  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 Apr 2010 Link to this post

    Hello,

    I've just tried this using our Q1 2010 binaries however the grid worked as expected. You can check the attached project for reference.

    Kind regards,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 15 Apr 2010 Link to this post

    Thank you Vlad.

    I figured out the (silly) problem. I forget to add the : INotifyPropertyChanged text next to my class.

    This is a result of working weeks and weeks only with WCF generated classes where you don't have to think about such things.

    Adding a bool in a custom class in the SL frontend app caused my frustration :-)

    Thanks,
    Nicolas
  10. Rajesh
    Rajesh avatar
    8 posts
    Member since:
    Apr 2012

    Posted 29 May 2012 Link to this post

    Hi Vlad,

    i have gone through your attachment it was simply awesome and thanks.
    when i click on button fine OnPropertyChanged property is getting fired.
    but when i click on check box on the client side(while running) OnPropertyChanged property should get fired(which is what my reqmnt) for that i used CellEditEnded event but im not getting the expected result.

    ok let me put my question in this way.. how can i do make OnPropertyChanged  fired on click of check box during runtime?
    could you please let me know how to make it editable on client side(which should get effect in the back end)

    Please try to reply me as soon as you can.
    Thanks in advance.

    Regards,
    Rajesh KS
Back to Top