日期:2014-05-18 浏览次数:21007 次
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Test"> <Style TargetType="{x:Type local:CC1}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:CC1}"> <Viewbox x:Name="MView"> <Grid Width="50" Height="50" x:Name="MGrid" Background="Red"> <Grid.RenderTransform> <TranslateTransform X="0" Y="0"/> </Grid.RenderTransform> </Grid> </Viewbox> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
public class CC1 : Control { static CC1() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CC1), new FrameworkPropertyMetadata(typeof(CC1))); } public void MoveTo(double x, double y) { // 控制MGrid的RenderTransform的TranslateTransform,请问如何控制? } }