开发者

Silverlight/Blend Datatrigger/EventTrigger STRANGE issue

My usercontrol contains 3000 NewDotControls in an itemscontrol. The ControlTemplate for NewDotControl is specified in a style that defines the visualstates and there is an eventtrigger that invokes a GotoStateAction on Loaded event.

<Controls:NewDotControl Style="{StaticResource MyDotStyle}"/>

Only around 445 of the 3000 NewDotControls go to the "Selected" state as defined by the EventTrigger whereas the rest of the NewDotControls do not. Same happens when I use DataTriggers that are bound to the ViewModel. The same xaml/code/app work in 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>

Why do DataTriggers/EventTriggers/GotoStateAction not work for all the 开发者_如何学运维controls in the ItemsControl?

If I remove the initial Loaded EventTrigger, around 775 to 800 NewDotControls respond to DataTriggers/GotoStateAction. If I hook up Commands to the control, the commands execute and modify the ViewModel Properties and fire PropertyChanged events, but still the DataTrigger/GotoStateAction does not happen.

What could I be missing? Is there a limit on the number of items in the itemscontrol that can be databound? Or is there an issue because this is in a ControlTemplate? Why does this work in WPF but not Silverlight?

Thanks!!! Rajesh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜