Select to view content in your preferred language

Legend Control Wait Indicator

743
2
12-01-2010 07:18 AM
PaulLeedham
Deactivated User
When using a templated version of the legend control, is there a way to add the wait indicator when loading the legend? I like the way the wait indicator functions on the basic legend control and I would like to apply the same functionality to the templated control.

Thanks,
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
Yes for sure you can have a wait indicator.

If you created your templated control with Blend by using the 'Copy' function, you should get it by default.

If you created your control from scratch or from VS, you can use (or adapt) this MapLayerTemplate which is the default:
 
<esri:Legend.MapLayerTemplate>
    <DataTemplate>
        <StackPanel>
            <StackPanel.Resources>
                <!-- Busy indicator displayed while the legend is requested-->
                <DataTemplate x:Key="BusyIndicatorTemplate">
                    <Grid x:Name="BusyIndicator" Background="Transparent" Margin="3,0" 
                                HorizontalAlignment="Left" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" >
                        <Grid.Triggers>
                            <EventTrigger RoutedEvent="Grid.Loaded">
                                <EventTrigger.Actions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:1" RepeatBehavior="Forever" To="360" Storyboard.TargetName="BusyIndicator"
                                                                    Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </Grid.Triggers>
                        <Grid.RenderTransform>
                            <RotateTransform />
                        </Grid.RenderTransform>
                        <Ellipse Fill="#1E525252" Margin="11,2,11,20" Width="2" Height="2"/>
                        <Ellipse Fill="#3F525252" Height="3" Width="3" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,4,5,0" />
                        <Ellipse Fill="#7F525252" Width="4" HorizontalAlignment="Right" Height="4" VerticalAlignment="Top" Margin="0,9,1,0" />
                        <Ellipse Fill="#BF525252" Height="5" Width="5" VerticalAlignment="Bottom" Margin="0,0,3,3" HorizontalAlignment="Right" />
                        <Ellipse Fill="#FF525252" Height="6" Width="6" VerticalAlignment="Bottom" Margin="9,0" />
                    </Grid>
                </DataTemplate>
            </StackPanel.Resources>
 
            <ToolTipService.ToolTip>
                <StackPanel MaxWidth="400">
                    <TextBlock FontWeight="Bold" Text="{Binding Layer.CopyrightText}" TextWrapping="Wrap" />
                    <TextBlock Text="{Binding Description}" TextWrapping="Wrap" />
                    <TextBlock Text="{Binding MinimumResolution, StringFormat='Minimum Resolution : {0:F6}'}" />
                    <TextBlock Text="{Binding MaximumResolution, StringFormat='Maximum Resolution : {0:F6}'}" />
                </StackPanel>
            </ToolTipService.ToolTip>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay}" IsEnabled="{Binding IsInScaleRange}" />
                <!--Opacity slider-->
                <Slider Margin="0,0,5,0" Minimum="0" Maximum="1" Width="30" Height="18" 
                            Value="{Binding Layer.Opacity, Mode=TwoWay}" />
                <!--Busy indicator-->
                <ContentControl ContentTemplate="{StaticResource BusyIndicatorTemplate}"
                            Visibility="{Binding BusyIndicatorVisibility}"/>
                <TextBlock Text="{Binding Label}" FontWeight="Bold" VerticalAlignment="Center" />
            </StackPanel>
        </StackPanel>
    </DataTemplate>
</esri:Legend.MapLayerTemplate>
0 Kudos
PaulLeedham
Deactivated User
Perfect!
Thanks Dominique.

I just wanted to let you guys know that your team out did yourself on this control--we spent a considerable amount of time building our own version. Nice Job!
0 Kudos