0

In my DataGrid, each row contains a RichTextBox.

EDIT : Here is how the RTB is placed in the DataGrid

<DataGrid>
   <DataGrid.Columns>
     <DataGridTemplateColumn x:Name="columnText" x:Uid="columnText" 
                                    Header="Text" 
                                    Width="*" 
                                    IsReadOnly="True"
                                    SortMemberPath="Text"
                                    CellTemplate="{StaticResource mainFormGridCell_columnText}"/>
   </DataGrid.Columns>
</DataGrid>

The DataTemplate is defined in a ResourceDictionary and looks roughly like this :

<DataTemplate x:Key="mainFormGridCell_columnText">
    <RichTextBox x:Name="rtbDiff" x:Uid="rtbDiff"/>
</DataTemplate>

What I need to do at runtime is fill the richtextbox of the SelectedItem with a FlowDocument. I now use the extension methods described here to find the Cell that contains that Control. With that I do the following :

DataGridCell cell = this.dgTexts.GetCell( this.dgFreetexts.GetSelectedRow(), 0 );
object ob = cell.Template.FindName( "rtbDiff", cell );

No matter how, I never find any Child with that Name - FindName always returns NULL. Does anybody have any ideas how I can improve my search for the RichTextBox?

Thanks in advance!

Sebastian Edelmeier
  • 4,095
  • 3
  • 39
  • 60

1 Answers1

0

I just found this neat solution.

Community
  • 1
  • 1
Sebastian Edelmeier
  • 4,095
  • 3
  • 39
  • 60