This question is locked. New answers and comments are not allowed.
Hello,
I am developing Silverlight application using MVVM design pattern and Telerik TreeView control. I want to pass the content of the Edited Node to ViewModel class. I am trying to do it like below. It doesn't work though. Please advise.
<telerikNavigation:RadTreeView Grid.Row="1" x:Name="tree" IsEditable="True" BorderThickness="1" BorderBrush="#FF9ABFE5" Margin="3">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Edited">
<i:InvokeCommandAction Command="{Binding ItemEditedCommand}" CommandParameter="{Binding CurrentTerritory, Mode=OneWay" />
</i:EventTrigger>
</i:Interaction.Triggers>
<telerikNavigation:RadTreeView.ItemTemplate>
<telerik:HierarchicalDataTemplate ItemsSource="{Binding Childs}" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
</StackPanel>
</telerik:HierarchicalDataTemplate>
</telerikNavigation:RadTreeView.ItemTemplate>
<telerikNavigation:RadTreeView.ItemContainerStyle>
<Style TargetType="telerikNavigation:RadTreeViewItem">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="IsExpanded" Value="True" />
</Style>
</telerikNavigation:RadTreeView.ItemContainerStyle>
<telerikNavigation:RadTreeView.ItemEditTemplate>
<DataTemplate>
<TextBox Text="{Binding Name, Mode=TwoWay}" >
</TextBox>
</DataTemplate>
</telerikNavigation:RadTreeView.ItemEditTemplate>
</telerikNavigation:RadTreeView>
public TerritoryListVM(IUIMessageBox uiMessageBox, AsyncCaller asyncCaller)
{
ItemEditedCommand = new DelegateCommand((a) => { this.ItemEditedCommandAction(a); }, (p) => { return true; });
LoadData();
}
public const string PnCurrentTerritory = "CurrentTerritory";
private TerritoryDB _currentTerritory;
public virtual TerritoryDB CurrentTerritory
{
get
{
return _currentTerritory;
}
set
{
if (_currentTerritory != value)
{
_currentTerritory = value;
OnPropertyChanged(PnCurrentTerritory);
}
}
}
public DelegateCommand ItemEditedCommand { get; set; }
private void ItemEditedCommandAction(object param)
{
string filter = param as string;
.......................................
}
I am developing Silverlight application using MVVM design pattern and Telerik TreeView control. I want to pass the content of the Edited Node to ViewModel class. I am trying to do it like below. It doesn't work though. Please advise.
<telerikNavigation:RadTreeView Grid.Row="1" x:Name="tree" IsEditable="True" BorderThickness="1" BorderBrush="#FF9ABFE5" Margin="3">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Edited">
<i:InvokeCommandAction Command="{Binding ItemEditedCommand}" CommandParameter="{Binding CurrentTerritory, Mode=OneWay" />
</i:EventTrigger>
</i:Interaction.Triggers>
<telerikNavigation:RadTreeView.ItemTemplate>
<telerik:HierarchicalDataTemplate ItemsSource="{Binding Childs}" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
</StackPanel>
</telerik:HierarchicalDataTemplate>
</telerikNavigation:RadTreeView.ItemTemplate>
<telerikNavigation:RadTreeView.ItemContainerStyle>
<Style TargetType="telerikNavigation:RadTreeViewItem">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="IsExpanded" Value="True" />
</Style>
</telerikNavigation:RadTreeView.ItemContainerStyle>
<telerikNavigation:RadTreeView.ItemEditTemplate>
<DataTemplate>
<TextBox Text="{Binding Name, Mode=TwoWay}" >
</TextBox>
</DataTemplate>
</telerikNavigation:RadTreeView.ItemEditTemplate>
</telerikNavigation:RadTreeView>
public TerritoryListVM(IUIMessageBox uiMessageBox, AsyncCaller asyncCaller)
{
ItemEditedCommand = new DelegateCommand((a) => { this.ItemEditedCommandAction(a); }, (p) => { return true; });
LoadData();
}
public const string PnCurrentTerritory = "CurrentTerritory";
private TerritoryDB _currentTerritory;
public virtual TerritoryDB CurrentTerritory
{
get
{
return _currentTerritory;
}
set
{
if (_currentTerritory != value)
{
_currentTerritory = value;
OnPropertyChanged(PnCurrentTerritory);
}
}
}
public DelegateCommand ItemEditedCommand { get; set; }
private void ItemEditedCommandAction(object param)
{
string filter = param as string;
.......................................
}