we have a RadTreeView whose rows are described with a template e.g checkbox,TextBox a, Textbox B ...however we need to be able to set the width of textbox at runtime. I tried to do the following:
private void ConceptBankTreeView_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
{
RadContextMenu ctx = new RadContextMenu();
RadTreeViewItem RowToBeDisplayed = e.PreparedItem as RadTreeViewItem;
TextBox tagsDisplayTxtBlk = (from aTxtBlk in RowToBeDisplayed.GetVisualDescendants().OfType<TextBox>()
where aTxtBlk.Name == "ConceptDisplayTxtBlk"
select aTxtBlk).FirstOrDefault();
if (tagsDisplayTxtBlk != null)
tagsDisplayTxtBlk.Width = 567;
with XAML that looks like:
<telerik:HierarchicalDataTemplate x:Key="ParentRow"
ItemsSource="{Binding ChildConcepts}" ItemTemplate="{StaticResource ChildRow}">
<Grid HorizontalAlignment="Stretch"
MinHeight="23">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<TextBox x:Name="ConceptDisplayTxtBlk"
Grid.Column="1"
HorizontalAlignment="Stretch"
Margin="0,3,0,0"
MinHeight="15"
Background="Transparent" BorderThickness="0"
Text="{Binding Display, Mode=OneWay}"
Width="160"
TextWrapping="Wrap"
VerticalAlignment="Center"
GotFocus="ConceptEditTxtBx_GotFocus"
MouseLeftButtonDown="ConceptDisplayTextBlock_MouseLeftButtonDown"/>
<!--<TextBox x:Name="ConceptEditTxtBx"
tagsDisplayTxtBlk is always null, Now the same code works after a right click operation.