DocumentWindow with ContentTemplateSelector

Docking/MDI for WPF Forum

Posted 9 years ago by Miron Sorin
Version: 10.2.0532
Avatar
Hello,

I have a problem in using the ContentTemplateSelector on DocumentWindow.

For example:
    MainWindow.xaml.cs
public MainWindow()
        {
            InitializeComponent();

            var docWin = new DocumentWindow()
                                        {
                                            Title = "title1",
                                            ContentTemplateSelector = (TemplateSelector)Resources["TSelector"],
                                            Content = "1"
                                        };
            grid.Children.Add(docWin);
        }
    MainWindow.xaml
<Window.Resources>
        <DataTemplate x:Key="FirstDataTemplate">
            <Label>FirstDataTemplate</Label>
        </DataTemplate>

        <DataTemplate x:Key="OtherDataTemplate">
            <Label>OtherDataTemplate</Label>
        </DataTemplate>

        <DockSiteTest:TemplateSelector x:Key="TSelector" 
                                       FirstDataTemplate="{StaticResource FirstDataTemplate}"
                                       OtherDataTemplate="{StaticResource OtherDataTemplate}">
        </DockSiteTest:TemplateSelector>
    </Window.Resources>
    
    <Grid x:Name="grid">
    </Grid>
    TemplateSelector
public class TemplateSelector : DataTemplateSelector
    {
        public DataTemplate FirstDataTemplate
        {
            get; set;
        }

        public DataTemplate OtherDataTemplate
        {
            get;
            set;
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item.ToString() == "1")
            {
                return FirstDataTemplate;
            }

            return OtherDataTemplate;
        }
    }
The problem is that the template selector is never queried. So the content of the window is allways "1".

Am I doing something wrong?

Comments (1)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Miron,

In the current version, the ContentTemplate and ContentTemplateSelector are not used when presenting the content. We've added support for these properties, which will be included in the next maintenance release.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.