Previously we hard several nested RadTabControl (s) and had defined IsXXSelected for each RadTabItem.
What I've done now is
ItemsSource="{Binding AvailableTabs}"
SelectedItem="{Binding SelectedTab, Mode=TwoWay}"
ItemTemplateSelector="{StaticResource _TabControlItemTemplateSelector}"
ContentTemplateSelector="{StaticResource _TabControlContentTemplateSelector}"
After this change I noticed when AutoLoad == true on QueryableDomainServiceCollectionView is making requests as *TemplateSelector generates a new container item.
This occurs because the view being regenerated has:
<telerikGrid:RadGridView.SortDescriptors>
<Data:SortDescriptor Member="Score"
SortDirection="Ascending" />
</telerikGrid:RadGridView.SortDescriptors>
Which affects SortDescriptors therefore triggering AutoLoad.
As you can see above I assumed it is because the ContainerFromItem must be generating a new one from *TemplateSelector so I tried caching the DataTemplate. I tried using base.SelectTemplate however it is always null. I also could not find any visualization setting on RadTabControl to disable removing generated container view.
These efforts did not solve the problem.
Any ideas on how i can resolve this problem when using DataTemplateSelector?
What I've done now is
ItemsSource="{Binding AvailableTabs}"
SelectedItem="{Binding SelectedTab, Mode=TwoWay}"
ItemTemplateSelector="{StaticResource _TabControlItemTemplateSelector}"
ContentTemplateSelector="{StaticResource _TabControlContentTemplateSelector}"
public
class
ResourceTemplateSelector : DataTemplateSelector
{
public
ResourceTemplateSelector()
{
Resources =
new
ResourceDictionary();
}
public
ResourceDictionary Resources {
get
;
set
; }
public
Dictionary<
object
, DataTemplate> _cache =
new
Dictionary<
object
, DataTemplate>();
public
override
DataTemplate SelectTemplate(
object
item, DependencyObject container)
{
var original =
base
.SelectTemplate(item, container);
if
(_cache.ContainsKey(item))
{
return
_cache[item];
}
string
contentTypeName = item.GetType().Name;
var contentTemplate = Resources[contentTypeName]
as
DataTemplate;
_cache.Add(item, contentTemplate);
return
contentTemplate;
}
}
After this change I noticed when AutoLoad == true on QueryableDomainServiceCollectionView is making requests as *TemplateSelector generates a new container item.
This occurs because the view being regenerated has:
<telerikGrid:RadGridView.SortDescriptors>
<Data:SortDescriptor Member="Score"
SortDirection="Ascending" />
</telerikGrid:RadGridView.SortDescriptors>
Which affects SortDescriptors therefore triggering AutoLoad.
As you can see above I assumed it is because the ContainerFromItem must be generating a new one from *TemplateSelector so I tried caching the DataTemplate. I tried using base.SelectTemplate however it is always null. I also could not find any visualization setting on RadTabControl to disable removing generated container view.
These efforts did not solve the problem.
Any ideas on how i can resolve this problem when using DataTemplateSelector?