Silverlight 4ではうまく動作するストーリーボードに3つのアニメーションがありますが、上記のエラーでSilverlight 5で失敗します。アニメーションは非常に単純です:Silverlight 5.0 SolidColorBrushのColorAnimationが "TargetNameを解決できません"で失敗する
<Storyboard x:Name="categoryChangeStoryboard">
<DoubleAnimation
Storyboard.TargetName="clueTransform"
Storyboard.TargetProperty="ScaleX"
Duration="0:0:0.4"
To="1.05"
RepeatBehavior="3x"
AutoReverse="True"
/>
<DoubleAnimation
Storyboard.TargetName="clueTransform"
Storyboard.TargetProperty="ScaleY"
Duration="0:0:0.4"
To="1.1"
RepeatBehavior="3x"
AutoReverse="True"
/>
<ColorAnimation
Duration="0:0:0.4"
Storyboard.TargetName="categoryForegroundBrush"
Storyboard.TargetProperty="Color"
From="Black"
To="LightGreen"
RepeatBehavior="3x"
AutoReverse="True"
/>
</Storyboard>
、それがアニメーションのオブジェクトも同様に非常に単純です:私たちは私たちは、次のエラーを取得する
categoryChangeStoryboard.Begin();
を呼び出す
<TextBlock x:Name="clue" Style="{StaticResource labelStyle}" Text="clue" FontSize="35" HorizontalAlignment="Right" MaxWidth="300" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Margin="0,90,80,0" RenderTransformOrigin=".5,.5">
<TextBlock.Foreground>
<SolidColorBrush Color="Black" x:Name="categoryForegroundBrush" />
</TextBlock.Foreground>
<TextBlock.RenderTransform>
<CompositeTransform x:Name="clueTransform"/>
</TextBlock.RenderTransform>
</TextBlock>
- だけのためにSilverlight 5:
{System.InvalidOperationException: Cannot resolve TargetName categoryForegroundBrush.
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
at System.Windows.Media.Animation.Storyboard.Begin()
at BCL.FLY.FLYVisual.CoreStateUpdateEvent(Object sender, FLYStateUpdateEventArgs e)
at BCL.FLY.FLYCore.OnStateUpdateEvent(FLYStateUpdateEventArgs e)
at BCL.FLY.FLYCore.Report(String msg, GameEventType t, Butterfly b)
at BCL.FLY.FLYCore.DebugGotoLevel(Int32 i)
at BCL.FLY.FLYVisual.DebugGotoLevel(Int32 n)
at BCL.FLY.FLYGame.GotoLevel(Int32 i)
at C8Live.MainPage.lvlSkip_SelectionChanged(Object sender, SelectionChangedEventArgs e)
at System.Windows.Controls.Primitives.Selector.OnSelectionChanged(SelectionChangedEventArgs e)
at System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(List`1 unselectedItems, List`1 selectedItems)
at System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
at System.Windows.Controls.Primitives.Selector.NotifyListItemSelected(ListBoxItem listBoxItem, Boolean isSelected)
at System.Windows.Controls.Primitives.Selector.OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
at System.Windows.DependencyObject.SetValue(DependencyProperty property, Boolean b)
at System.Windows.Controls.Primitives.Selector.OnListBoxItemClicked(ListBoxItem item)
at System.Windows.Controls.ListBoxItem.OnMouseLeftButtonDown(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonDown(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)}
誰もが考えを持っていますか?その単一のColorAnimationを削除しても問題は解決しますが、そのままにしておくことをお勧めします。
labelStyleはフォアグラウンドブラシを設定しますか? – cadrell0
これは非常に面白いです。私は単純なプロジェクトにコードをコピーして、すべて正常に動作します。できれば、スタイルを共有することもできますか?あなたのスタイルがTextblockの前景色をオーバーライドしているため、上書きされたSolidColorBrush xを見つけることができないようです:名前付きcategoryForeGroundBrush –
@Danimal、サンプルプロジェクトでコードを実行しました。私はあなたのラベルを見て、これを再現する必要があります。 – KodeKreachor