StackPanel
StoryBoard
<Window x:Class="WpfApp_ColourTextBlock.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen"> <Window.Resources> <System:String x:Key="textBlockName">textBlock0</System:String> <Storyboard x:Key="Storyboard1"> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="{DynamicResource textBlockName}"> <EasingColorKeyFrame KeyTime="0:0:2.5" Value="Red"/> <EasingColorKeyFrame KeyTime="0:0:5" Value="Blue"/> <EasingColorKeyFrame KeyTime="0:0:7.5" Value="Red"/> <EasingColorKeyFrame KeyTime="0:0:10" Value="White"/> </ColorAnimationUsingKeyFrames> </Storyboard> </Window.Resources> <Grid> <StackPanel Name="TextBlocks" Orientation="Horizontal"> </StackPanel> </Grid> </Window>
TextBlock
public MainWindow() { InitializeComponent(); TextBlock tb = new TextBlock(); tb.Uid = "textBlock1"; tb.Text = "test"; TextBlocks.Children.Add(tb); Resources["textBlockName"] = "textBlock1"; (Resources["Storyboard1"] as Storyboard).Begin(); }
'textBlock0' name cannot be found in the name scope of 'WpfApp_ColourTextBlock.MainWindow'.
TargetName
myMainPanel.RegisterName(button1.Name, button1);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)