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
1925
Hierarchical datasource xamDiagram style using datatrigger based on enum
posted

Please take a look at the attached example of hierarchical datasoure bound to xamDiagram.


I want to change the background of nodes based on employee type enum value, say if its admin employee background to take a colour and if academic staff then node should take different colour.


I tried using datatriggers but could not achieve it. Please help.

Parents
No Data
Reply
  • 34690
    Offline posted

    Hello Abs,

    Thank you for your post.

    Unfortunately, I was unable to see the sample project that you had attached, as it appears that the file may have corrupted, and so I am unable to extract or view the contents of your attached .zip file.

    I do have a couple of recommendations on this matter, though. While I can't really see what your DataTrigger looks like, I would recommend that you write a Style for DiagramNode in this case. Binding your DataTrigger to the data context of that node will not help on this matter, though, as the data context of the nodes in the XamDiagram share the same data context as the diagram itself. Instead, each of these nodes have a Content property which should represent the underlying item of that particular node. So, if you were to bind to the following in your DataTrigger, you should be able to check the enum value and set the background property of your nodes:

    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content.EnumPropertyName}" Value="someValue" >

    I hope this helps. Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

Children