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
170
Dynamic Conditional formatting
posted

hello,

The "conditional formatting" sample for xamnetworknode shows how to specify different node styles during design time with NodeControl.Style.
Can we do this dynamically by binding using "VisualStateManager"?

I have tried creating a custom node style (template) including VSM to define states with animations(color animations) based on device status and want to apply this to the nodes.
What should be the values for "storyboard.targetproperty" if I want to apply the style to nodetype "Switch" in networknodenodecontrol to change background of the node as per animations.

Pls refer the following xaml code. The style I am trying to apply:

 <Style x:Key="NormalNodeStyle" TargetType="ig:NetworkNodeNodeControl">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ig:NetworkNodeNodeControl">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="RGTGroup">
                                    <VisualState x:Name="GreenBlinking">
                                        <Storyboard RepeatBehavior="Forever">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="xnn" Storyboard.TargetProperty="Background">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF007700"/>
                                                <SplineColorKeyFrame KeyTime="00:00:01" Value="#FF007700"/>
                                                <SplineColorKeyFrame KeyTime="00:00:01.5000000" Value="#FF007700"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Blue">
                                        <Storyboard >
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="xnn" Storyboard.TargetProperty="Background">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF0000FF"/>
                                                <SplineColorKeyFrame KeyTime="00:00:01" Value="#FF0000FF"/>
                                                <SplineColorKeyFrame KeyTime="00:00:01.5000000" Value="#FF0000FF"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

and xamnetworknode  as

<ig:XamNetworkNode x:Name="xnn"
                           SelectionType="Extended"
                           ItemsSource="{Binding IGNetworkDevices}"
                           OverviewPlusDetailPaneVisibility="Visible"
                           Padding="0"
                           BorderThickness="0" Margin="-4,10,10,60" Loaded="xnn_Loaded_1" NodeDistance="0">

            <ig:XamNetworkNode.GlobalNodeLayouts>

                <ig:NetworkNodeNodeLayout TargetTypeName="Switch"
                     ConnectionsMemberPath="Connections"
                    ConnectionTargetMemberPath="Target"
                    OverridesDefaultStyle="True" Margin="0" NodeStyle="{StaticResource NormalNodeStyle}">
                <ig:NetworkNodeNodeLayout TargetTypeName="Switch"
                     ConnectionsMemberPath="Connections"
                    ConnectionTargetMemberPath="Target"
                    OverridesDefaultStyle="True" Margin="0" NodeStyle="{StaticResource NormalNodeStyle}">
<ig:NetworkNodeNodeLayout>



Sandy.

Parents Reply Children