Hi,
I'm using the timeline in a slightly different way as a selection mechanism.
I use the event title style to house a checkbox which is part of my selection work flow.
Here's a snippet of the style
AND HERE IS THE WHOLE POST THAT WAS STRANGELY CROPPED
<Style x:Key="XamEventTitleStyle" TargetType="ig:EventTitle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ig:EventTitle">
<Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"
BorderThickness="1" ToolTip="{Binding PreviewTooltip}">
<DockPanel Grid.Row="0" x:Name="dockWhite">
<CheckBox IsChecked="{Binding Selected}" Margin="{TemplateBinding Padding}" DockPanel.Dock="Left"/>
</DockPanel>
You can see that the Selected property is bound to each of the event tiles.
This all works well until I attempt to perform a 'select all' by iterating through the tiles and setting the Selected bound property. In this situation the perform is painfully slow.
Looking underneath the hood when the bound selected property is signalled via an OnPropertyChanged this kicks off a Timelines.XamTimeline.SeriesChanged event which in turn performs a reposition of all the tiles which is clearly unnecessary as only a checkbox state is being changed.
Is there any way to prevent the series changed event from firing when performing a 'builk' operation such as select all on all the tiles?
Thanks in advance for any help you can provide
S
Hi Simon,
I built a sample and tried this out myself. I can definitely see the performance issues when trying to select all the checkboxes via property change events. Currently I'm not sure why changing a property which is technically unrelated to the timeline event is triggering the SeriesChanged event. It looks like there is an event listening for changes on the ItemsSource and this is triggering the SeriesChanged event so it's likely that we are not checking which property triggered the change. I need to check the source code directly to see for sure. Right now I'm just analyzing through a performance profiler.
I'm going to crack open the source code for the timeline and see how exactly the ItemsSource changed event is being triggered. I'll then try and come up with a workaround you can use to avoid this.
Looks like the timeline is just handling the PropertyChanged event for each item in the DataSource and then regardless of what property is triggering the event it is calling SeriesChanged which is arranging the series elements. Doing this for every single DataSource item will cause a noticeable hang if there are a significant number of items.
In order to resolve this we would need to modify the source code so I have logged this as a development issue for our development team to assess and make the appropriate changes. The development issue ID is 212030. I also created a private support case for you so that you may track the status of this dev issue. The case number is CAS-168323-V6K0T2 and you can view it here.
I did manage to come up with a workaround that will speed things up but it involves removing the property change notifications on your Selected property. Instead I opted to create a behavior that will listen for changes in the checkbox and then use reflection to update the underlying Selected property. SelectAll is implemented by notifying each CheckBox that it needs to update its IsChecked state. This is done by attaching the behavior to every CheckBox and then hooking into a static event. When you call the static SelectAll() method on the behavior class it will fire this event which notifies each CheckBox individually. When the checkbox is notified it then updates the underlying Selected property. I also created a Sync method you can use in order to make changes to individual Selected properties and have it update the UI to reflect the change.
I attached a sample that demonstrates the workaround.
Thanks for your time and effort on this, the workaround does indeed fix the immediate problem.
Best Regards
Actually I just noticed that using the workaround for my ig:EventTitle has disabled my datatrigger which used Selected.
ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Selected}" Value="True">
<Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}" TargetName="dockWhite"/>
<Setter Property="Foreground" Value="White"/>
</DataTrigger>
</ControlTemplate.Triggers>
Is there any way to deal with this?
Many Thanks
Sorry for the late reply, hopefully this will still be useful.
The trigger doesn't work because we took out the property notifications on the Selected property in order to work around the performance issue. Since there is no property notifications the DataTrigger won't react anymore. What you can do is change the trigger to look at the Checkbox's IsChecked property instead. Give the Checkbox an x:Name and then use a normal Trigger, setting the SourceName property to the checkbox name. The new trigger will look like this:
<Trigger SourceName="chkbox1" Property="IsChecked" Value="True"> <Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}" TargetName="dockWhite"/> <Setter Property="Foreground" Value="White"/> </Trigger>
Perfect, thanks