3

我在让滚动条显示在我的 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;
}

我所看到的图片:

在此处输入图像描述

内容出现在信息窗口中,但找不到滚动条。希望这很简单,我觉得我已经尝试了一切。提前致谢。

4

1 回答 1

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 中

于 2013-07-09T09:27:09.240 回答