*下面的代码很好,问题出在其他地方 - 离开这里,其他人需要信息。
我正在创建一个具有大型可滚动可缩放Canvas
的模拟器。我需要在这个画布上放置一个StackPanel
(或其他),但它不应该滚动或缩放。这就是我所拥有的:
<Grid>
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Label Content="{Binding Date, StringFormat=Date: {0}}"/>
<Label Content="{Binding CO2Level}"/>
<Label Content="{Binding O2Level}"/>
<Label Content="{Binding H2OLevels}"/>
<Label Content="{Binding TempC}"/>
<Label Content="{Binding TempF}"/>
<Label Content="{Binding SolarLevels}"/>
</StackPanel>
<ScrollViewer Name="scrollViewer" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<Grid Name="grid" Width="65535" Height="65535" RenderTransformOrigin="0.5, 0.5">
<Grid.LayoutTransform>
<TransformGroup>
<ScaleTransform x:Name="scaleTransform"/>
</TransformGroup>
</Grid.LayoutTransform>
<Canvas x:Name="canvas" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="0" Height="0" RenderTransform="1 0 0 -1 0 0">
<!-- Setup automatic viewing of Lifeforms -->
<ItemsControl ItemsSource="{Binding Entities}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Path Data="{Binding Geometry}"
Fill="{Binding Fill}"
StrokeThickness="0"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Canvas>
</Grid>
</ScrollViewer>
</Grid>
然而它不起作用,lebels根本没有出现,我无法弄清楚如何做到这一点。有什么想法吗?