Select to view content in your preferred language

Accessing VisualStateManager

1117
1
12-09-2011 05:44 AM
oo
by
Emerging Contributor
<esri:SimpleRenderer x:Key="MySimpleRendererLines">
                <esri:SimpleRenderer.Symbol>
                    <esri:LineSymbol>
                        <esri:LineSymbol.ControlTemplate>
                            <ControlTemplate>
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="MouseOver">
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="Element" Storyboard.TargetProperty="(Shape.StrokeThickness)" BeginTime="0" Duration="00:00:00" To="6" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Normal">
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="Element" Storyboard.TargetProperty="(Shape.StrokeThickness)" BeginTime="0" Duration="00:00:00" To="2" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Selected">
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="Element" Storyboard.TargetProperty="(Shape.StrokeThickness)" BeginTime="0" Duration="00:00:00" To="6"/>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Path x:Name="Element" Stroke="Black" StrokeThickness="2" />
                                </Grid>
                            </ControlTemplate>
                        </esri:LineSymbol.ControlTemplate>
                    </esri:LineSymbol>
                </esri:SimpleRenderer.Symbol>
            </esri:SimpleRenderer>

I have the above Renderer in my xaml and would like to change the VisualState of a Symbol programmatically like this:
VisualStateManager.GoToState(_MySymbol, "Normal", true);

My problem is, I have not found a way to access the VisualStateManager (so far I can only access the ControlTemplate via
SimpleRenderer sr = LayoutRoot.Resources["MySimpleRendererLines"] as SimpleRenderer;
ControlTemplate ct = sr.Symbol.ControlTemplate;


Thanks for your help!
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor

My problem is, I have not found a way to access the VisualStateManager

AFAIK it's not possible.

Not sure why you want to access the VisualStatemanager but note that your symbol is wrong.
You have to define 2 VisualStateGroups : 'CommonStates' and 'SelectionStates' with respectively the states ('Normal', 'MouseOver') and ('Selected', 'Unselected'). Once defined, the state changes will be managed by the SL API.
0 Kudos