0

Working on a WP8.1 application in Windows Runtime.

I have a large UserControl defined inside the DataTemplate for a ListViews -

<DataTemplate x:Key="ListItemTemplate">
            <listItems:ListItemControl />
</DataTemplate>

Which is used as so -

<ListView x:Name="List"
          ItemTemplate="{ThemeResource ListItemTemplate}"
          ShowsScrollingPlaceholders="True"
          SelectionMode="None"
          ContainerContentChanging="ListOnContainerContentChanging"
          ScrollViewer.VerticalScrollBarVisibility="Auto" />

Will this have any negative performance impact compared with laying out all the items directly in the DataTemplate?

I've read that using a UserControl vs Templated Control has a big perf difference due to the UserControl xaml having to be processed each time. I'm unsure if in this case it will only have to be processed once as it is located in the DataTemplate.

BradStevenson
  • 1,974
  • 7
  • 26
  • 40

2 Answers2

1

I'd check my answer to this question for comparison of UserControl and templated controls:

When to use a templated control over a UserControl?

Aside from that - YMMV. With performance the first rule is to not optimize prematurely so you might not need to worry unless you have a problem. The second rule is to do measurements - find your baseline to compare against. The third is to do profiling to find out what exactly is slow if you want to find out what to improve.

In many cases - it won't really matter which method you use. Some say a template is typically only parsed once, while each UserControl instance will need to load the XAML (or XBF) over and over.

Community
  • 1
  • 1
Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
0

There is no question that a UserControl has a performance penalty. I worked for Microsoft on a Silverlight project and we did not use UserControl because of performance issues. I have read where a group converted from the UserControl because of performance. I would recommend avoiding the UserControl is the design is simple. I would say go ahead with the Usercontrol if you do not have any performance issues since it is much easy to work with UserConstrols than straight datatemplats.