I discovered anevil(because very hard to find) bug, which cost me at least an hour of my time (just because I was lucky, and tried unlikely stuff out).
XamOrgChart tries to outsmart the coder, and evaluates all public properties, and if the type of the property is IEnumerable, it's obviously treated as ItemsSource (for the Children) (or whatever XamOrgChart does).
I created a small example demonstrating the problem:
XAML:
<
UserControl xmlns:ig="http://schemas.infragistics.com/xaml" x:Class
="XamOrgChartBug.MainPage"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
="d"
d:DesignHeight="300" d:DesignWidth
="400">
<Grid x:Name="LayoutRoot" Background
="White">
<ig:XamOrgChart
InitialTreeDepth
="2"
LevelsToExpand
="1"
ItemsSource="{Binding
.}"
>
<ig:XamOrgChart.GlobalNodeLayouts
<ig:OrgChartNodeLayout
TargetTypeName
="Tree_Type"
Key="Children"
DisplayMemberPath
="Text"
</ig:OrgChartNodeLayout
</ig:XamOrgChart.GlobalNodeLayouts
</ig:XamOrgChart
</Grid
</
UserControl
Xaml.cs:
public partial class MainPage :
{
public
MainPage()
InitializeComponent();
var root = new Tree_Type
()
Parent =
null
,
Text =
"root"
};
root.Children =
Enumerable.Range(0, 3).Select(x => new Tree_Type
Parent = root,
"c"
+ x,
});
this.DataContext = new Tree_Type
[] { root };
}
public class
Tree_Type
public string Text { get; set
;}
public IEnumerable<Tree_Type> Children { get; set
; }
public Tree_Type Parent { get; set
public IEnumerable<Tree_Type
> Parents
get
var p = this
.Parent;
while (p != null
)
yield return
p;
p =
this
When the project is started, it crashes with a meaningless error - if ran on IIS, you get "StackOverflow" exception. (probably IIS responsible...not sure - at least in my real project I got stackoverflow).
If the property "Parents" is commented in class "Tree_Type" there is no crash, and XamOrgChart is displayed.
What the heck is XamOrgChart doing with my public properties?! It should only touch those properties which I defined in the Xaml!!!
Regards
Johannes
In my example, there is a bug in the Parents-property, when this bug is fixed, the "correct error" (StackOverflow) is displayed, the corrected code for the Parents-property:
> ParentsXXXXXXX
p = p.Parent;
Hello,
We have shipped out a new service release where your issue is resolved. I'd be glad to find out if you had tested it out and if it had met your requirements.
You can download the Service Releases by logging to our web site and going to Account \Keys & Downloads.
https://es.infragistics.com/my-account/keys-and-downloads/