This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have created a class that inherits from TypeTemplate that enables me to have two different NodeTemplates applied depending on the value of the "Enabled" property of a custom FlowDiagramNode. Is there a way that I can force the diagram to re-evaluate the templates as I am changing the Enabled property in code and need to apply the other template? |
|
|
Having spent some time looking into this I have concluded the following (in case it is of use to others): Background research included http://www.pluralsight-training.net/community/blogs/dbox/archive/2007/10/01/48635.aspx which led me to the post by Neil Mosafi in http://social.msdn.microsoft.com/forums/en-US/wpf/thread/faf81960-ca5d-4256-b08b-cbabc7d5516e/ The solution means that I have implemented my required functionality using data triggers only and don't have to create a template matcher class inheriting from TypeTemplate any more. Now I can take the default style for the EndNode which looks something like:
<DataTemplate x:Key="EndNodeTemplate"> <Grid> <Border Name="Border" Background="DarkRed" CornerRadius="15" Style="{StaticResource BrightStyleBaseStyle}" BorderThickness="0" Padding="1" > <Border CornerRadius="14" Background="{StaticResource EndNodeBackground}" /> </Border> <ContentPresenter Name="ContentPresenter" Content="{Binding}" ContentTemplateSelector="{Binding NodeContentTemplateSelector, RelativeSource={RelativeSource AncestorType={x:Type ms:DiagramNodeElement}}}" /> </Grid> <DataTemplate.Triggers> <Trigger SourceName="ContentPresenter" Property="ContentTemplateSelector" Value="{x:Null}"> <Setter TargetName="ContentPresenter" Property="ContentTemplate" Value="{StaticResource NodeContentTemplate}" /> </Trigger> </DataTemplate.Triggers> </DataTemplate> Then create the "Disabled" template: <DataTemplate x:Key="EndNodeDisabledTemplate"> <Grid> <Border Name="Border" Background="Gray" CornerRadius="15" Style="{StaticResource BrightStyleBaseStyle}" BorderThickness="0" Padding="1" > ... ...
Now I create the selector template: <DataTemplate x:Key="EndNodeTemplateSelectorKey"> <ContentPresenter Content="{Binding}" Name="cp" /> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Enabled}" Value="True"> <Setter TargetName="cp" Property="ContentTemplate" Value="{StaticResource EndNodeTemplate}" /> Then my FlowDiagramFormatter looks like: <ms:FlowDiagramFormatter x:Key="Formatter" NodeTemplateSelector="{StaticResource NodeTemplateSelector}" ...
...
<ms:MatchingTemplateSelector x:Key="NodeTemplateSelector">
<ms:TypeTemplate DataType="bb:MyEndNode" Template="{StaticResource EndNodeTemplateSelectorKey}" />
Now I have a node who template will change if the Enabled property of the node changes.
|
|