Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Working binding expressions throw errors in XamDataTree
posted

Hi, I am experiencing some binding issues with XamDataTree v13.1 for WPF.

I have some triggers in my global node layouts that work perfectly, but regardless of that bindingexpressen errors occur in the output.

The code below is fetched from a view with a viewmodel called SituationTreeViewModel. This viewmodel contains a datasource for the tree called SituationWrappers:

<ig:XamDataTree Name="Tree" Grid.Row="1" VerticalAlignment="Top" ItemsSource="{Binding SituationWrappers}">

<ig:XamDataTree.GlobalNodeLayouts>
<ig:NodeLayout Key="SituationViewLayout" TargetTypeName="SituationWrapper" DisplayMemberPath="Name"
ExpandedIconTemplate="{StaticResource SituationIconTemplate}"
CollapsedIconTemplate="{StaticResource SituationIconTemplate}">
<ig:NodeLayout.NodeStyle>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Data.IsActive}" Value="False">
<Setter Property="FrameworkElement.Opacity" Value="0.5"/>
</DataTrigger>
<DataTrigger Binding="{Binding Data.IsVisible}" Value="True">
<Setter Property="TextBlock.FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ig:NodeLayout.NodeStyle>
</ig:NodeLayout>
</ig:XamDataTree.GlobalNodeLayouts>
</ig:XamDataTree>

As I mentioned the triggers given in the global node layouts work, but for some reason the tree tries to first access the given data-properties on the root view model itself (SituationTreeViewModel). This results in the following errors: 

System.Windows.Data Error: 40 : BindingExpression path error: 'Data' property not found on 'object' ''SituationTreeViewModel' (HashCode=12529951)'. BindingExpression:Path=Data.IsActive; DataItem='SituationTreeViewModel' (HashCode=12529951); target element is 'XamDataTreeNodeControl' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 40 : BindingExpression path error: 'Data' property not found on 'object' ''SituationTreeViewModel' (HashCode=12529951)'. BindingExpression:Path=Data.IsVisible; DataItem='SituationTreeViewModel' (HashCode=12529951); target element is 'XamDataTreeNodeControl' (Name=''); target property is 'NoTarget' (type 'Object')

Is there a way to avoid these binding issues, I'd rather not have them cluttering up my output log?

Hope you can help,

Best Regards,

Tommy W.