I am working with DataTemplate to dynamically change the view of my UI.
However, I found that the performance is quite unacceptable.
Here is my code:
Xaml (Views.xaml):
<ResourceDictionary>
<DataTemplate .... x:name="D1" ....../>
<DataTemplate .... x:name="D2" ....../>
<DataTemplate .... x:name="D3" ....../>
<DataTemplate .... x:name="D4" ....../>
</ResourceDictionary>
Code:
ResoucesDictionary RD = Application.LoadComponent(new Uri("../Views.xaml", UriKind.Relative)) as ResourceDictionary;
if (...condition..)
{
MyGroupBox.ContentTemplate = RD["D1"] as DataTemplate;
}
else if (....condition...)
{
MyGroupBox.ContentTemplate = RD["D2"] as DataTemplate;
}
.....
.....
....
.
....
else
{
.......
}
MyGroupBox is an instance of GroupBox in my UI. I want the View of the GroupBox change in run time so that I use DataTemplate.
However, I found that it show the correct UI after > 0.5 seconds whenever a particular condition is triggered.
Is that the performance of DataTemplate so poor? Or is there anything I missed? or wrong?
Thank you very much.