【发布时间】:2017-01-04 10:53:36
【问题描述】:
我找到了一个示例,如果我删除了ScrollViewer,它运行良好,但我需要ScrollViewer 中的图像。 TextBox 应该是图像的叠加层。
在此示例中,图像不在ScrollViewer 内。有人可以告诉我如何在里面添加图像吗?
<Image Grid.Column="2" HorizontalAlignment="Center" Source="/Images/Italien.png"
Stretch="None"/>
<ScrollViewer Grid.Column="2" Margin="2,2,2,2" HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible">
<ItemsControl ItemsSource="{Binding Tests}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas IsItemsHost="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="123" Foreground="Aqua" Background="Transparent"
FontSize="10" TextAlignment="Justify" BorderBrush="Red"
BorderThickness="1" Width="{Binding Width}"
Height="{Binding Height}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Image>
【问题讨论】: