Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Animation based on property value
    primarykey
    data
    text
    <p>I have a dependency property <strong>double Text</strong>, and what I want to accomplish is to rotate (with animation) a line by <strong>Text</strong> degrees whenever I change the value of <strong>Text</strong> property.</p> <p>Is there a better way than to implement OnTextPropertyChanged and there process the animation? Or could that be done rather in XAML?</p> <p>Here is a demonstrating code:</p> <p>MainWindow.xaml</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:l="clr-namespace:WpfApplication1" x:Class="WpfApplication1.MainWindow" Title="MainWindow" Height="200" Width="200" x:Name="Root"&gt; &lt;Grid&gt; &lt;TextBox Width="50" Height="20" VerticalAlignment="Top" Text="{Binding Text, ElementName=Root, Mode=TwoWay}"/&gt; &lt;Grid Width="100" Height="100" Background="Gray" x:Name="Grid"&gt; &lt;Line Grid.Row="1" X2="100" Y2="100" Stroke="Red"/&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>and MainWindow.xaml.cs (without usings):</p> <pre><code>namespace WpfApplication1 { public partial class MainWindow : Window { public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(double), typeof(MainWindow), new FrameworkPropertyMetadata(0.0)); public double Text { get { return (double)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public MainWindow() { InitializeComponent(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload