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.
Hello Sandy,
I am just checking if you require any further assistance on the matter.
Hello,
Thank you for your reply.In the "Conditional formatting" example where visual states respond to mouse events like "mouse over" and "selected", I would like the visual states in my custom style to respond to PropertyChanged event of a property specified in my code behind. How do I proceed for the data binding? can specifying UIElement.Opacity work in this case too? If so, how to respond to state change in the code behind.
Thanks
Hi Sandy,
Thank you for your reply. I have been looking into your requirement and I believe that it cannot be achieved because the visual states are defined for controls. They represent the visual appearance of the control when it is in a specific state. For more information about this, you could look into the following link:
http://msdn.microsoft.com/en-us/library/system.windows.visualstate%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager%28v=vs.110%29.aspx
The ‘PropetyChanged’ event is not part of the control, it is event related to its view model. This is not related specific to our control. This is valid for all controls.
Let me know, if you need any further assistance on this matter.
hi Yanko,
I am aware that visual states are defined for controls only. I have attached a sample prog where I am changing visual states of a "user control" based on the 'property changed' event in the code behind. For your reference, In the code, The state manager class contains a dependency property that works on the visual state. The state of 'rectangle' control changes in response to a 'timer_tick' event in the code.
Now , can I do a similar thing for xamnetworknode? The node background should change in response to a timer tick event or any event described in the code.
In the example on "conditional formatting" visual states respond to "mouseover" or "selected". can these states be changed?
Thank you for your reply. Currently all the visual states of the XamNetworkNode control are defined in the ‘NetworkNodeNodeControl.cs’ file in the source code of the control like:
[TemplatePart(Name = ExpanderButtonName, Type = typeof(ToggleButton))]
[TemplateVisualState(Name = VisualStates.StateNormal, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateMouseOver, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StatePressed, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateDisabled, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateReadOnly, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateFocused, GroupName = VisualStates.GroupFocus)]
[TemplateVisualState(Name = VisualStates.StateUnfocused, GroupName = VisualStates.GroupFocus)]
[TemplateVisualState(Name = VisualStates.StateSelected, GroupName = VisualStates.GroupSelection)]
[TemplateVisualState(Name = VisualStates.StateUnselected, GroupName = VisualStates.GroupSelection)]
[TemplateVisualState(Name = StateEditing, GroupName = GroupEdit)]
[TemplateVisualState(Name = StateNotEditing, GroupName = GroupEdit)]
public class NetworkNodeNodeControl : ContentControl, IUpdateVisualState
{
…
}
http://help.infragistics.com/Help/Doc/WPF/2014.2/CLR4.0/html/xamNetworkNode_Display_VisualStates.html
The desired requirement is custom and in order to create your own visual state you need to buy our product in order to download the source code and define your visual state there. Since this requirement is out of the support scope, if you need any further assistance on this matter, you could contact our consulting team. For more information:
http://www.infragistics.com/support/support-policies
Let me know, if you have any other questions on this matter.