小智 6
一种简单的方法是只使用Canvas并将canvas的background属性设置为您的照片,然后将您的圆或矩形放在其上并使用Canvas.Left和.Top属性定位它们.
<Canvas x:Name="myCanvas">
<Canvas.Background>
<ImageBrush ImageSource="c:\photo.bmp"/>
</Canvas.Background>
<Image Canvas.Top="20" Canvas.Left="20" Height="20" Width="20" Source="c:\circle.bmp"/>
</Canvas>
Run Code Online (Sandbox Code Playgroud)
我设法做了类似的事情:
ItemsControl在它上面放一个透明的ItemsControl.ItemsPanel为Canvas代码片段:
<ItemsControl x:Name="overlayItemsControl"
Background="Transparent"
ItemsSource="{Binding Path=Blocks}"
Width="{Binding ElementName=imageControl, Path=Width}"
Height="{Binding ElementName=imageControl, Path=Height}"
ItemContainerStyle="{StaticResource rectStyle}"
PreviewMouseMove="ItemsControl_PreviewMouseMove"
PreviewMouseDown="ItemsControl_PreviewMouseDown"
PreviewMouseUp="ItemsControl_PreviewMouseUp"
PreviewKeyDown="ItemsControl_PreviewKeyDown">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
....
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19576 次 |
| 最近记录: |