We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

TabControlExt ItemTemplate Binding to MVVM Property of DataContext

Hello,

we have a problem with the TabControlExt ItemTemplate.
We want to use a Property of our ViewModel (MVVM Style with PRISM) to show the Title of the TabItem.
But as we can see, the TabItem could not reach the properties of the TabControl content.
In the content we display view dynamically loaded.

Is there any option the get the properties or set the title by binding to the viewmodel presented in the content area?
In order to that problem, is there also an option to set the closing icon dynamically with a property of the viemodel?
Not all of our views should be closed by the user itself.

An example of the code:

<sf:TabControlExt x:Name="Tab"
                      prism:RegionManager.RegionName="{x:Static modinf:ModuleRegionNames.ModulPosteingangTabRegion}"
                      AllowDragDrop="false"
                      CloseButtonType="Hide"
                      EnableLabelEdit="False"
                      RotateTextWhenVertical="true"
                      ShowTabItemContextMenu="False"
                      ShowTabListContextMenu="False"
                      TabItemLayout="SingleLine"
                      TabItemSize="Normal"
                      TabScrollButtonVisibility="Auto"
                      TabScrollStyle="Extended"
                      TabStripPlacement="Top">
        <sf:TabControlExt.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Path=DataContext.ViewModelTitel}" />
            </DataTemplate>
        </sf:TabControlExt.ItemTemplate>
We tried Content.DataContext., only Datacontext. and without.

Thanks and best regards
Ben

3 Replies

DR Durga Rajan Syncfusion Team January 25, 2017 09:10 AM UTC

Hi Benjamin Siegmund,

Thank you for contacting Syncfusion support.

We have prepared a sample to meet your requirement. In the sample, we have bound the Header property of Model to TabItem Header using ItemContainerStyle property of TabControlExt. Using BoolToCloseTypeConverter and CanClose property in Model, we have changed the CloseButtonType of TabControlExt to avoid displaying close button for few tab items. You can download the sample for the same from the following location.

Sample: TabControlExt_Prism_Sample

If we have misunderstood your query, please get back to us with more details about your ​​​requirement. This would help us to provide solution at earliest.

Regards,
Durga S.


BS Benjamin Siegmund January 26, 2017 06:42 AM UTC

Hello Durga S.,

thank you for your fast reply. It works fine. Thanks a lot :)


MS Marimuthu Sivalingam Syncfusion Team January 26, 2017 01:47 PM UTC

Hi Benjamin,

We are glad to know that your issue has been solved. Please let us know if you need any further assistance.

Regards,
Marimuthu S.


Loader.
Live Chat Icon For mobile
Up arrow icon