将TransformGroup添加到wp7中的TransformGroup

时间:2013-10-23 14:27:51

标签: c# wpf xaml windows-phone-7

我在文本框上应用rendertransform,我想在TransformGroup对象中添加一个TransformGroup对象。 为此,我在xaml中做的有点像这样。

                  <TextBox.RenderTransform>
                    <TransformGroup>
                        <MatrixTransform x:Name="previousTransform" />

                        <TransformGroup x:Name="currentTransform">
                            <ScaleTransform x:Name="scaleTransform" />
                            <RotateTransform x:Name="rotateTransform" />
                            <TranslateTransform x:Name="translateTransform" />
                        </TransformGroup>
                    </TransformGroup>
                </TextBox.RenderTransform>

它按照我预期的方式工作,现在我想在c#中发生同样的事情,我已经创建了一个TransformGroup对象并设法为它添加变换。现在我想将此变换组添加到另一个变换组对象,就像我在xaml中所做的那样但是,我不知道该怎么做。 请对我将用于实现它的财产或方法提出建议。

感谢。

1 个答案:

答案 0 :(得分:2)

      var textBox = new TextBox();
      var transformGroup = new TransformGroup()
          {
              Children = new TransformCollection()
                  {
                      new MatrixTransform(), 
                      new TransformGroup
                      { 
                          Children = new TransformCollection()
                          {
                              new ScaleTransform(), 
                              new RotateTransform(), 
                              new TranslateTransform()
                          }
                      }
                  }
          };

      textBox.RenderTransform = transformGroup;
相关问题