Select to view content in your preferred language

Hide Verticalscrollbar in Legend

658
5
01-24-2012 11:22 PM
SantoshV
Emerging Contributor
HI,
I have a Legend which shows a disabled scrollbar even if the content is limited within the panel.
my XAML is as follows
<esri:Legend Map="{Binding ElementName=map}" Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                         ShowOnlyVisibleLayers="True" x:Name="CustomLegend" Refreshed="CustomLegend_Refreshed" >                        
                        
                        <esri:Legend.MapLayerTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                        <sdk:Label Content="{Binding Description}"/>
                                    <!--<Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" />-->
                                </StackPanel>
                            </DataTemplate>
                        </esri:Legend.MapLayerTemplate>
                        <esri:Legend.LegendItemTemplate>
                            <DataTemplate >
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding ImageSource}"></Image>
                                    <sdk:Label Content="{Binding Label}" MinWidth="50"/>
                                    <sdk:Label Content="{Binding Tag}"/>
                                </StackPanel>
                            </DataTemplate>
                        </esri:Legend.LegendItemTemplate>
                        <esri:Legend.LayerTemplate>
                            <DataTemplate>
                                <CheckBox Content="{Binding Label}"
                               IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                            IsEnabled="{Binding IsInScaleRange}" >
                                </CheckBox>
                            </DataTemplate>
                        </esri:Legend.LayerTemplate>
                </esri:Legend>


How can I hide the scrollbar

Please guide..
0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor
I have a Legend which shows a disabled scrollbar even if the content is limited within the panel
.

The default legend template uses a TreeView which has a built-in scrollviewer.
But this scrollviewer should not be visible if not needed.

Look at this sample : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LegendSimple The scrollbars are only visible when needed.

If, for any reason, you need to change the default behavior, you can restyle the legend control (using EditTemplate functionalty in Blend) and use any other container to replace the treeview.
0 Kudos
SantoshV
Emerging Contributor
.

The default legend template uses a TreeView which has a built-in scrollviewer.
But this scrollviewer should not be visible if not needed.

Look at this sample : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#LegendSimple The scrollbars are only visible when needed.

If, for any reason, you need to change the default behavior, you can restyle the legend control (using EditTemplate functionalty in Blend) and use any other container to replace the treeview.


HI thanks for your reply tried everything but still unable to hide it.
the scroll is disabled but is always visible

my code goes like this
<Grid x:Name="panelCustomLegend" HorizontalAlignment="Right" Margin="0,50,80,0" VerticalAlignment="Top" ScrollViewer.VerticalScrollBarVisibility="Hidden"
                        Visibility="Visible" Background="Black" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <sdk:Label Name="lblCustomLegend" Foreground="White" Grid.Row="0" MinWidth="50" MaxWidth="200" HorizontalAlignment="Center" FontSize="12" />

                    <esri:Legend Map="{Binding ElementName=map}" Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                         ShowOnlyVisibleLayers="True" x:Name="CustomLegend" Refreshed="CustomLegend_Refreshed" >                        
                        
                        <esri:Legend.MapLayerTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                        <sdk:Label Content="{Binding Description}"/>
                                    <!--<Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" />-->
                                </StackPanel>
                            </DataTemplate>
                        </esri:Legend.MapLayerTemplate>
                        <esri:Legend.LegendItemTemplate>
                            <DataTemplate >
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding ImageSource}"></Image>
                                    <sdk:Label Content="{Binding Label}" MinWidth="50"/>
                                    <sdk:Label Content="{Binding Tag}"/>
                                </StackPanel>
                            </DataTemplate>
                        </esri:Legend.LegendItemTemplate>
                        <esri:Legend.LayerTemplate>
                            <DataTemplate>
                                <CheckBox Content="{Binding Label}"
                               IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                            IsEnabled="{Binding IsInScaleRange}" >
                                </CheckBox>
                            </DataTemplate>
                        </esri:Legend.LayerTemplate>
                </esri:Legend>
            </Grid>


[ATTACH=CONFIG]11518[/ATTACH]


Can you please guide me with the modification to hide to scroll

.....
0 Kudos
SantoshV
Emerging Contributor
HI,

I have website with mouseover information tool where i run a query from the database everytime the mouse moves over the map
but when  I move the mouse towards the window edges/corners the information texblock is chopped away it is not absolute
Please guide me as to how the keep the mouse over information within the map boundary
my code goes like this
<!--MouseOver Information-->
            <Border x:Name="m_maptip" CornerRadius="10,10,0,0"
                VerticalAlignment="Top" HorizontalAlignment="Left"  Visibility="Collapsed" 
                Background="White" BorderThickness="3" BorderBrush="#3c91c0" Opacity="0.8">
                <StackPanel>
                    <sdk:Label x:Name="m_txt_maptip_header" FontFamily="Arial" FontSize="16" Foreground="Red"/>
                    <TextBlock x:Name="m_txt_maptip" Text="Line" Foreground="Black" FontSize="12"/>
                </StackPanel>
            </Border>


I populate the information into the textblock dynamically


                KeyValuePair<int, string> kvpIdentifyLayer = (KeyValuePair<int, string>)cmbxLayerIdentify.SelectedItem;
                m_txt_maptip.Text = strDisplayInfo;
                m_txt_maptip_header.Content = "Layer: " + kvpIdentifyLayer.Value;
                m_maptip.Visibility = Visibility.Visible;
                m_maptip.Margin = new Thickness(_last_point.X + 10, _last_point.Y + 10, 0, 0);
                m_txt_maptip_header.Width = m_txt_maptip.Width;


Please guide
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The default legend style doesn't show disabled scrollbars.

Check that there is no implicit style defined for the legend in your project (most generally in app.xaml) that might override the default template.
0 Kudos
SantoshV
Emerging Contributor
The default legend style doesn't show disabled scrollbars.

Check that there is no implicit style defined for the legend in your project (most generally in app.xaml) that might override the default template.

Hey dbroux thanks
you were right the legend style was defined in app.xaml
I changed it

it solved my problem

thanks a bunch 🙂
0 Kudos