Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将矩形的边界从一个画布调整到另一个画布?_C#_Wpf - Fatal编程技术网

C# 如何将矩形的边界从一个画布调整到另一个画布?

C# 如何将矩形的边界从一个画布调整到另一个画布?,c#,wpf,C#,Wpf,我在XAML中具有以下结构: <Grid> <ItemsControl x:Name="Items" ItemsSource="{Binding Path=Pages}" Grid.Row="0" Grid.Column="0"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" />

我在XAML中具有以下结构:

<Grid>
  <ItemsControl x:Name="Items" ItemsSource="{Binding Path=Pages}" Grid.Row="0" Grid.Column="0">
    <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Vertical" />
      </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

    <ItemsControl.ItemTemplate>
      <DataTemplate>
        <!-- Display a white page for each page item -->
        <local:PageView Margin="0, 25, 0, 0" />
      </DataTemplate>
    </ItemsControl.ItemTemplate>
  </ItemsControl>

  <!-- Layer used for displaying preview of drawn shape -->
  <local:PreviewLayer x:Name="PreviewLayer" Grid.Row="0" Grid.Column="0"/>
</Grid>
但是我不知道如何得到页面视图的坐标。使用
Canvas.GetLeft(pageView)
返回
NaN


如何获得页面视图边界?

我可以通过使用
translatePoint
找到它。起初它不起作用,直到我发现
ContainerFromItem
返回一个项目的容器(如果您读取函数名,这是合乎逻辑的,但我想这超出了我的理解范围)


获取容器的第一个子元素返回了
translatePoint

所需的元素,我可以使用
translatePoint
找到它。起初它不起作用,直到我发现
ContainerFromItem
返回一个项目的容器(如果您读取函数名,这是合乎逻辑的,但我想这超出了我的理解范围)

获取容器的第一个子级返回了我需要的元素
translatePoint

UIElement pageView = (UIElement)this.Items.ItemContainerGenerator.ContainerFromItem(page);