天天看点

WPF 与Surface 2.0 SDK 亲密接触 - 图形缩放篇

     通过上一篇的介绍大家应该已经了解到ScatterView 可以使开发者方便的实现控件的Manipulate 操作。细心的朋友可能发现了前面示例中矩形的缩放似乎有些问题,为了便于说明我们编写如下代码。

<Grid>      <s:ScatterView>          <Rectangle Fill="Blue" Width="200" Height="100"/>          <Ellipse Fill="Red" Width="150" Height="80"/>      </s:ScatterView>  </Grid>        

     在ScatterView 中分别加入了矩形和椭圆形,并且为两个图形分析别限定了长、宽尺寸。当我们对图形进行缩放操作时发现,两个图形本身尺寸并没有发生任何变化,只有ScatterViewItem 尺寸变大了。似乎图形的大小已经被长、宽参数约束住了。

<Grid>      <s:ScatterView>          <Rectangle Fill="Blue" Width="200" Height="100"/>          <Viewbox>              <Rectangle Fill="Red" Width="200" Height="100"/>          </Viewbox>      </s:ScatterView>  </Grid>        

继续阅读