<p>I create ItemsControl: </p>
<p> <ItemsControl Grid.ColumnSpan="3" ItemsSource="{Binding MyItemsSource}" ItemTemplate="{StaticResource MyDataTemplate}" /></p>
<p> </p>
<p>ItemsControl has MyDataTemplate:</p>
<p> </p>
<p><DataTemplate x:Key="DayShiftViewModelDataTemplate"></p>
<p> <Grid Background="Red"></p>
<p> <TextBlock Text="FooText"/> </p>
<p> <controlsInputToolkit:ContextMenuService.ContextMenu></p>
<p> <controlsInputToolkit:ContextMenu ></p>
<p> <controlsInputToolkit:MenuItem UseLayoutRounding="False" Header="asdfsdf" Command="{Binding AddNewShiftCommand}"/></p>
<p> </controlsInputToolkit:ContextMenu></p>
<p> </controlsInputToolkit:ContextMenuService.ContextMenu></p>
<p> </Grid> </p>
<p> </DataTemplate></p>
<p> </p>
<p>When I clear the collection of ItemsSource and add new elements , my application starts to slow.</p>
<p>If I delete Context Menu from DataTemplate, application works well.</p>
Comments: ** Comment from web user: davemateer **
<p> <ItemsControl Grid.ColumnSpan="3" ItemsSource="{Binding MyItemsSource}" ItemTemplate="{StaticResource MyDataTemplate}" /></p>
<p> </p>
<p>ItemsControl has MyDataTemplate:</p>
<p> </p>
<p><DataTemplate x:Key="DayShiftViewModelDataTemplate"></p>
<p> <Grid Background="Red"></p>
<p> <TextBlock Text="FooText"/> </p>
<p> <controlsInputToolkit:ContextMenuService.ContextMenu></p>
<p> <controlsInputToolkit:ContextMenu ></p>
<p> <controlsInputToolkit:MenuItem UseLayoutRounding="False" Header="asdfsdf" Command="{Binding AddNewShiftCommand}"/></p>
<p> </controlsInputToolkit:ContextMenu></p>
<p> </controlsInputToolkit:ContextMenuService.ContextMenu></p>
<p> </Grid> </p>
<p> </DataTemplate></p>
<p> </p>
<p>When I clear the collection of ItemsSource and add new elements , my application starts to slow.</p>
<p>If I delete Context Menu from DataTemplate, application works well.</p>
Comments: ** Comment from web user: davemateer **
I too struggled with this. In fact I couldn't get the it to work, and ended up implementing my own right click events which drew a menu, and gave me what I needed. Would be great to see an example of a 'fix' here working -
I tried: apudale wrote Oct 17 at 7:28 AM's ... comment... looked good.. but couldn't get it to work.