Binding Set Property Called Twice !

5 posts, 1 answers
  1. Kannan
    Kannan avatar
    26 posts
    Member since:
    Nov 2009

    Posted 20 Oct 2010 Link to this post

    Hi All,

    I'm using rad grid view having one column.
    I've binded using DataTemplate like this,

     

    <

     

     

    telerikGridView:RadGridView

     

     

     

     

    Name="radGridView"

     

     

     

     

    AutoGenerateColumns="False"

     

     

     

     

     

    ItemsSource="{Binding RowValues, Mode=TwoWay}">

     

     

     

     

     

     

    <telerikGridView:RadGridView.Columns>

     

     

     

     

    <!--<telerikGridView:GridViewDataColumn Header="Column # 1" DataMemberBinding ="{Binding ColumnOneValue, Mode=TwoWay}"/>-->

     

     

     

     

     

     

    <telerikGridView:GridViewDataColumn Header="Column # 1" DataMemberBinding ="{Binding ColumnOneValue}">

     

     

     

     

     

    <telerikGridView:GridViewDataColumn.CellTemplate>

     

     

     

    <DataTemplate>

     

     

     

     

     

     

     

    <Grid>

     

     

     

     

     

    <TextBlock Text="{Binding ColumnOneValue}"></TextBlock>

     

     

     

    </Grid>

     

     

     

     


    </
    DataTemplate>

     

     

     

     


    </
    telerikGridView:GridViewDataColumn.CellTemplate>

     

     

     

     

    <telerikGridView:GridViewDataColumn.CellEditTemplate>

     

     

     

     

     

     

     

    <DataTemplate
     

    <Grid>

     

     

     

     

    <TextBox Text="{Binding ColumnOneValue, Mode=TwoWay}"></TextBox>

     

     

     

     

     

    </Grid>

     

     

     

     

     

    </DataTemplate>

     

     

     

     

     

    </telerikGridView:GridViewDataColumn.CellEditTemplate>

     

     

     

     

     

    </telerikGridView:GridViewDataColumn>

     

     

     

     

     

    </telerikGridView:RadGridView.Columns>

     

     

     

     

     

    </telerikGridView:RadGridView>

     

     

     

     

     

    I change the value in the first cell of first row and then click the first cell in the second row.
    At that time the binded set property is called twice.
    I want that property should be called only once, since I'm doing validation and showing error message.


    Following is the stack trace when the set property is called for the first time,

     Grid!Grid.RowValue.ColumnOneValue.set(string value) Line 51 
      [Native to Managed Transition] 
      [Managed to Native Transition] 
      System.Windows.dll!System.Windows.CLRPropertyListener.Value.set(object value) + 0x23 bytes 
      System.Windows.dll!System.Windows.PropertyAccessPathStep.Value.set(object value) + 0x10 bytes 
      System.Windows.dll!System.Windows.Data.BindingExpression.UpdateValue() + 0x3b2 bytes 
      System.Windows.dll!System.Windows.Data.BindingExpression.TargetLostFocus(object sender, System.Windows.RoutedEventArgs e) + 0xb bytes 
      System.Windows.dll!MS.Internal.CoreInvokeHandler.InvokeEventHandler(int typeIndex, System.Delegate handlerDelegate, object sender, object args) + 0x7bc bytes 
      System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj, System.IntPtr unmanagedObjArgs, int argsTypeIndex, int actualArgsTypeIndex, string eventName) + 0x338 bytes 
      [Appdomain Transition] 

    Following is the stack trace when the set property is called for the second time,

     Grid!Grid.RowValue.ColumnOneValue.set(string value) Line 51 
      [Native to Managed Transition] 
      [Managed to Native Transition] 
      System.Windows.dll!System.Windows.CLRPropertyListener.Value.set(object value) + 0x23 bytes 
      System.Windows.dll!System.Windows.PropertyAccessPathStep.Value.set(object value) + 0x10 bytes 
      System.Windows.dll!System.Windows.Data.BindingExpression.UpdateValue() + 0x3b2 bytes 
      System.Windows.dll!System.Windows.Data.BindingExpression.UpdateSource() + 0x28 bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridViewBoundColumnBase.UpdateBindingBaseSource(System.Windows.Data.BindingExpression bindingBase, System.Windows.DependencyObject source) + 0x75 bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridViewBoundColumnBase.UpdateSourceWithEditorValue(Telerik.Windows.Controls.GridView.GridViewCell gridViewCell) + 0x21c bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewCell.UpdateSourceWithEditorValue() + 0x43 bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.ValidateCell(Telerik.Windows.Controls.GridView.GridViewCell cell) + 0x12b bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.PerformCellValidation(Telerik.Windows.Controls.GridView.GridViewCell cell) + 0x4d bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(Telerik.Windows.Controls.GridView.GridViewCell currentCell, bool isLeavingRow) + 0xa3 bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.OnCurrentCellInfoChanging(Telerik.Windows.Controls.GridViewCellInfo oldCell, Telerik.Windows.Controls.GridViewCellInfo newCell) + 0xa1 bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.CurrentCellInfo.set(Telerik.Windows.Controls.GridViewCellInfo value) + 0x7d bytes 
      Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewCell.OnGotFocus(System.Windows.RoutedEventArgs e) + 0xc9 bytes 
      System.Windows.dll!System.Windows.Controls.Control.OnGotFocus(System.Windows.Controls.Control ctrl, System.EventArgs e) + 0x31 bytes 
      System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj, System.IntPtr unmanagedObjArgs, int argsTypeIndex, int actualArgsTypeIndex, string eventName) + 0x234 bytes 
      [Appdomain Transition] 

    Please let me know where I'm doing wrong ? Thank you !

    Thanks & Regards,
    Kannan

  2. Kannan
    Kannan avatar
    26 posts
    Member since:
    Nov 2009

    Posted 20 Oct 2010 Link to this post

    Hi All,

    I've uploaded the sample application which is used to replicate this issue in the following path, Thanks !

    http://www.4shared.com/account/dir/cimuGlr3/sharing.html?sId=9tVQLn4AwPfk145M

    Thanks & Regards,
    Kannan
  3. Answer
    Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 22 Oct 2010 Link to this post

    Hi Kannan,

    Indeed this is an expected behavior when CellEditTemplate is used.
    You could set Binding.UpdateSourceTrigger property to Explicit and then this property will be updated only by RadGridView's editing and validation mechanism (in fact this is what RadGridView internally does with the default editors).

    <TextBox Text="{Binding ColumnOneValue, Mode=TwoWay, UpdateSourceTrigger=Explicit}"></TextBox>

    Another solution is to check value if it is same like current value (to avoid code inside property setter).

    if (_ColumnOneValue != value)
    {
    _ColumnOneValue = value;
    }

    I hope this will help.

    All the best,
    Nedyalko Nikolov
    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
  4. Kannan
    Kannan avatar
    26 posts
    Member since:
    Nov 2009

    Posted 22 Oct 2010 Link to this post

    Hi Nedyalko Nikolov 

            Yes, this works. Thank you !

            I used the code: UpdateSourceTrigger=Explicit

            I can't used the other work around since I'm already having in the set property.

            That check is necessary there because the set property is called every time if the cell is double clicked.

    Thanks & Regards,
    Kannan
  5. Vadim
    Vadim avatar
    8 posts
    Member since:
    Feb 2009

    Posted 26 Oct 2011 Link to this post

    But it doesn't work if I use RadSlider as EditTemplate. I've get a same error!
Back to Top