or
When I click on a row in my TreeListView, I get a NullReferenceException error in my SelectionChanged method:
<telerik:RadTreeListView Name="equipmentTreeView" Margin="8" Background="Beige" ItemsSource="{Binding FirstGeneration}" telerik:StyleManager.Theme="Vista" IsDragDropEnabled="True" SelectionMode="Single" SelectionUnit="FullRow" SelectionChanged="equipmentTreeView_SelectionChanged" IsSynchronizedWithCurrentItem="False" AutoGenerateColumns="False" > <telerik:RadTreeListView.ChildTableDefinitions> <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" /> </telerik:RadTreeListView.ChildTableDefinitions> <telerik:RadTreeListView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding TagName}" Header="{l:Translate ModuleEquipmentNavigator_ColumnHeaderTag}" Width="Auto"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="{l:Translate ModuleEquipmentNavigator_ColumnHeaderDesc}" Width="Auto"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding ImportedEquipmentType}" Header="{l:Translate ModuleEquipmentNavigator_ColumnHeaderIET}" Width="Auto"/> </telerik:RadTreeListView.Columns></telerik:RadTreeListView>
public class AssetRowItem{ public string TagName { get; set; } public string Description { get; set; } public string ImportedEquipmentType { get; set; }}
private void equipmentTreeView_SelectionChanged(object sender, SelectionChangeEventArgs e){ AssetRowItem aRI = this.equipmentTreeView.SelectedItem as AssetRowItem; string message = string.Format("Tag Name: {0} \n Description: {1} \n Imported Equipment Type: {2}", aRI.TagName, aRI.Description, aRI.ImportedEquipmentType); MessageBox.Show(message);}
<telerik:RadWindow x:Class="IdealHost.FaceToFace.Controls.MessageBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" MinHeight="140" MinWidth="300" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ><Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="80" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="1" Margin="15,10,15,10" Name="txtMessage" /> </Grid></telerik:RadWindow>this.txtMessage.Text = message;<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="1" Margin="15,10,15,10" Text="{Binding Message}"/>private void VerbindungForm1_EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndedEventArgs e){ if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit) { ?????????? }}