weird behaviour in RowDetailTemplate

May 5, 2009 at 12:18 PM
Im Using WPF ToolKit March release.Im Having require ment like this:- Datagrid is populated with collection of customer object. Datagrid consists of 2 Template column.each Teamplate column consists of one Button.Namely Button1 ,Button2.When the User click on Button1 Row Detail should be visible .RowDetail consists of Stackpanel with TextBox. On Click of Button ,I writing in code behind for button click 

  DataGridRow drp = DataGridRow.GetRowContainingElement(sender as Button);  //gets Current Row of Button Clicked

(drp.DetailsTemplate.LoadContent() as StackPanel).FindName("TextBox1").Text = "Some Value"; Set the Text to TextBox1

whenever user clicks on Button2 of same row,RowdetailTemplate 's Textbox is not populated with NewValues.
Some How above code is not wrking 

Even I moved code to LoadingRowDetails i.e On Clicking of Button Im calling LoadingRowDetails,First time it loads with correct value but next time i click on Another Button in the same row,it doesnot reflect with new value (which i set).

Code is wrking by moving code RowDetailsVisibilityChanged event ,It is wrking fine,But this event has to fire twice.because if there is change in visiblity of rowdetails then this event fires.First time rowdetail visiblity change from collapse to Visible state,  when i click on 2nd button,since rowdetail visiblity is visible,RowDetailsVisiblityChanged event doesnot fire.

Does any1 faced same issue.

With Regards,

May 6, 2009 at 11:35 AM
I would be interested in this answer as well.

Does the RowDetailsVisibilityChanged event only fire when the Visibilty is set to Visible and not when set to collapsed?

Mahender, are you using the March or the Jan toolkit currently?

Jul 15, 2009 at 7:48 AM

any solution or work around for this problem??

Jul 15, 2009 at 8:07 PM


There is work around for this kind of situation.Inspite of creating style in xaml file

and retrieve datatemplate in code -behind and changing state of control like change text or assigning click functionality dynamically etc .

We have to create Framework element dynamically and assign to control template of Row details

Psedo code:-

Create a Framework Element Factory instance ,which is of Textbox /Buttton etctype.

Set the Bindings or values to FrameElement Factory Instance

and assign FrameworkElement Factory instance to Visual Tree of control Template of RowDetailTemplate

No Need to create Style in XAML.