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
405
Binding Errors in Style for NetworkNodeNodeControl
posted

Normal 0 false false false EN-US X-NONE X-NONE

I am attempting to style the nodes based on properties on the "NodeModel".  I have the following code inside the NetworkNodeNodeLayout:

<ig:XamNetworkNode ItemsSource="{Binding Nodes}" >

    <ig:XamNetworkNode.GlobalNodeLayouts>

        <ig:NetworkNodeNodeLayout NodeStyle="{StaticResource NodeStyle}" TargetTypeName="NodeModel"


My NodeStyle looks like the following:

<Style x:Key="NodeStyle" TargetType="ig:NetworkNodeNodeControl">

    <Setter Property="Background" Value="{Binding NodeType, Converter={StaticResource NodeToColorConverter}}"/>

    <Setter Property="Foreground" Value="Black"/>

    <Setter Property="Visibility" Value="{Binding Visible}"/>            

</Style>

The "NodeType" and "Visible" bindings in the style are both properties found on the "NodeModel".
When running the program the immediate window spits out a binding error for every single node in the network.
The view has its DataContext set to a viewModel that exposes a "Nodes" property.

You can see this behavior by running the attached project and viewing the immediate window after the view loads.  This is the output that spams:


System.Windows.Data Error: 40 : BindingExpression path error: 'NodeType' property not found on 'object' ''BindingErrorsViewModel' (HashCode=66354235)'. BindingExpression:Path=NodeType; DataItem='BindingErrorsViewModel' (HashCode=66354235); target element is 'NetworkNodeNodeControl' (Name=''); target property is 'Background' (type 'Brush')
System.Windows.Data Error: 40 : BindingExpression path error: 'Visible' property not found on 'object' ''BindingErrorsViewModel' (HashCode=66354235)'. BindingExpression:Path=Visible; DataItem='BindingErrorsViewModel' (HashCode=66354235); target element is 'NetworkNodeNodeControl' (Name=''); target property is 'Visibility' (type 'Visibility')

QUESTION:
Why are there binding failures?  Why is the NodeStyle looking to the view model for the properties Visible and NodeType instead of using the NodeModel's properties?

 

Kind Regards,

Daniel

 

PS Let me know if a support ticket would be a better option.

NetworkNodeIssues.zip
Parents
  • 138253
    Verified Answer
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into it and the sample you provided and I suggest you change the Bindings in you NtworkNodeNodeControl Style to the following ones:

    <Style x:Key="NodeStyle" TargetType="ig:NetworkNodeNodeControl">
        <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self},Path=Node.Data.NodeType, Converter={StaticResource NodeToColorConverter}}"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Visibility" Value="{Binding RelativeSource={RelativeSource Self},Path=Node.Data.Visible,UpdateSourceTrigger=PropertyChanged}"/>
    </Style>
    

     

    Hope this helps you.

Reply Children