2017-01-25 8 views
0

xamlコードをプログラムで表現する方法がわかりません。このxamlからどのようにしたらよいでしょうか? :C#プログラムでXAMLを表現する方法TranslateTransform

<TextBlock FontFamily="Vijaya" FontSize="16" Name="textscroll" Margin="35,330,330,21" Foreground="LightSteelBlue" Text="BLA-BLA&#13;bla-bla again"> 
     <TextBlock.RenderTransform> 
      <TranslateTransform x:Name="TRANCE_X" /> 
     </TextBlock.RenderTransform> 
     <TextBlock.Triggers> 
      <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
       <BeginStoryboard> 
        <Storyboard RepeatBehavior="1x"> 
         <DoubleAnimation 
          From="-300" To="0" 
          Storyboard.TargetName="TRANCE_X" 
          Storyboard.TargetProperty="Y" 
          Duration="0:0:1" /> 
        </Storyboard> 
       </BeginStoryboard> 
      </EventTrigger> 
     </TextBlock.Triggers> 
    </TextBlock> 
+0

namespace WpfCSharpSandbox { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); WidenObject(150, TimeSpan.FromSeconds(1)); } private void WidenObject(int newWidth, TimeSpan duration) { DoubleAnimation animation = new DoubleAnimation(newWidth, duration); rctMovingObject.BeginAnimation(Rectangle.WidthProperty, animation); } } } 

これは次のようにXAMLがどのように見えるかです、C#で同じ結果を達成する? – MonsieurMan

+0

はい。まったく。私は試みましたが、正しい構文を見つけることができません。 –

答えて

0

私はDoubleAnimationコードをC#で検索して、何をしたいかを見つけました。リンクをクリックするだけではなく、便宜的にSolution

は、ここでの答えの例です:あなたがプログラムでそれを表現するとはどういう意味ですか

<Window x:Class="WpfCSharpSandbox.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Sandbox" Height="350" Width="525"> 
    <Grid Background="#333333"> 
     <Rectangle x:Name="rctMovingObject" Fill="LimeGreen" Width="50" Height="50"/> 
    </Grid> 
</Window> 
+0

幾何学的な矩形の例をありがとうが、私はtextbox/textblock内のtext.based遷移をしたい。 "textblock rendertransform"、 "translatetransform"、およびトリガの使用に関するXAMLをC#に "変換"する方法を理解できません。 –

関連する問題