这是我的xml
<Window.Resources>
<sampleData:MainWindow x:Key="DataSource"/>
<DataTemplate x:Key="CustomComponentParameter">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
<HierarchicalDataTemplate x:Key="CustomComponent" ItemTemplate="{StaticResource CustomComponentParameter}"
ItemsSource="{Binding Parameters }">
<TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
</Window.Resources>
用于 Telerik 控制
<telerik:RadTreeView ItemsSource="{Binding Source={StaticResource DataSource},Path=SummaryViewCollection}" ItemTemplate="{StaticResource CustomComponent}" HorizontalAlignment="Left" Height="77" Margin="345,482,0,0" VerticalAlignment="Top" Width="449">
</telerik:RadTreeView>
这是我的代码隐藏类
主代码隐藏类 MainWindow.xaml.cs 的代码
public partial class MainWindow : Window
{
public ObservableCollection<CustomComponent> SummaryViewCollection { get; set; }
public MainWindow()
{
this.SummaryViewCollection = //code to fill in the details
}
}
这是 CustomComponentClass 的代码
public class CustomComponent
{
private ObservableCollection<CustomComponentParameter> parameters = new ObservableCollection<CustomComponentParameter>();
public string Name
{
get;
set;
}
public ObservableCollection<CustomComponentParameter> Parameters
{
get
{
return this.parameters;
}
set
{
this.parameters = value;
}
}
}
CustomComponentParameter 类的代码
public class CustomComponentParameter
{
public string Name
{
get;set;
}
public string Value
{
get;set;
}
public bool HasErrors
{
get;set;
}
public bool IsDuplicate
{
get;set;
}
public bool IsMissing
{
get; set;
}
}
每次我运行它时,我都会收到以下错误“在 mscorlib.dll 中发生'System.StackOverflowException'类型的未处理异常”。无法计算表达式,因为当前线程处于堆栈溢出状态。对此有何建议?谢谢