私のユーザーコントロールには、項目コントロールに 3000 個の NewDotControls が含まれています。NewDotControl の ControlTemplate は、visualstates を定義するスタイルで指定され、Loaded イベントで GotoStateAction を呼び出すイベントトリガーがあります。
<Controls:NewDotControl Style="{StaticResource MyDotStyle}"/>
3000 個の NewDotControl のうち約 445 個のみが、EventTrigger によって定義された「選択済み」状態になりますが、残りの NewDotControlsはそうではありません。ViewModel にバインドされている DataTriggers を使用すると、同じことが起こります。同じ xaml/code/app が WPF で機能します。
<Style x:Key="MyDotStyle" TargetType="Control">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Control">
<Viewbox x:Name="viewbox" RenderTransformOrigin="0.5,0.5"
>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="UnSelected">
</VisualState>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeThickness)" Storyboard.TargetName="InnerEllipse" d:IsOptimized="True">
<EasingDoubleKeyFrame KeyTime="0" Value="2"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<ei:GoToStateAction StateName="Selected"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Ellipse x:Name="InnerEllipse" Stroke="Red" StrokeThickness="0" RenderTransformOrigin="0.5,0.5"/>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
DataTriggers/EventTriggers/GotoStateAction が ItemsControl のすべてのコントロールで機能しないのはなぜですか?
最初の Loaded EventTrigger を削除すると、約 775 ~ 800 個の NewDotControls が DataTriggers/GotoStateAction に応答します。コマンドをコントロールに接続すると、コマンドが実行されて ViewModel プロパティが変更され、PropertyChanged イベントが発生しますが、それでも DataTrigger/GotoStateAction は発生しません。
何が欠けている可能性がありますか?データバインドできる項目コントロールの項目数に制限はありますか? または、これは ControlTemplate にあるために問題がありますか? これが WPF では機能するのに、Silverlight では機能しないのはなぜですか?
ありがとう!!!ラジェッシュ