ScrollBar没有出现

时间:2013-07-03 15:42:06

标签: c# xaml arcgis infowindow esri

我在使用InfoWindow显示滚动条时遇到问题。代码如下。任何帮助将不胜感激。

XAML:

<DataTemplate x:Key="MyFeatureLayerInfoWindowTemplate">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ItemsControl ItemsSource="{Binding Keys}" Grid.Column="0" />
        <ItemsControl ItemsSource="{Binding Values}" Grid.Column="1" />
    </Grid>
</DataTemplate>

<esri:InfoWindow x:Name="MyInfoWindow"
                 CornerRadius="20"
                 ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}"
                 Map="{Binding ElementName=MyMap}"
                 MouseLeftButtonUp="MyInfoWindow_MouseLeftButtonUp" 
                 ScrollViewer.VerticalScrollBarVisibility="Visible"
                 ScrollViewer.HorizontalScrollBarVisibility="Visible"
                 Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
                 MaxHeight="200"
                 MaxWidth="200"/>

C#:

if (clickpoint != lastPoint)
{
    MyInfoWindow.Anchor = clickpoint;
    MyInfoWindow.Content = e.Graphic.Attributes;
    MyInfoWindow.IsOpen = true;
    lastPoint = clickpoint;
}

我所看到的图片:

enter image description here

内容显示在InfoWindow中,但滚动条无处可寻。希望这很简单,我觉得我已经尝试了一切。提前谢谢。

1 个答案:

答案 0 :(得分:1)

试试这个

<DataTemplate x:Key="MyFeatureLayerInfoWindowTemplate">
  <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ItemsControl ItemsSource="{Binding Keys}" Grid.Column="0" />
        <ItemsControl ItemsSource="{Binding Values}" Grid.Column="1" />
    </Grid>
  </ScrollViewer>
</DataTemplate>

我的意思是:将网格包裹在ScrollViewer