poudigne
poudigne

Reputation: 1766

Programmatically Add ContentTemplate to TabControl

I have this TabControl

        <TabControl x:Name="tcProvince" Margin="2" ItemsSource="{Binding Path=WorkingEntity.Rates.CodeByProvinceCollection, Mode=OneWay}" SelectionChanged="tcProvince_SelectionChanged" >
        <TabControl.ContentTemplate>
            <DataTemplate>
                <max:MaxGrid>
                    <max:MaxGrid.RowDefinitions>

                    </max:MaxGrid.RowDefinitions>
                    <max:MaxGrid.ColumnDefinitions>

                    </max:MaxGrid.ColumnDefinitions>


                </max:MaxGrid>
            </DataTemplate>
        </TabControl.ContentTemplate>

    </TabControl>

This generate a tab like this: enter image description here

Then inside of each Tab I want to create a dynamic grid like this:

+-------+-------+--------+-------+
| 2016  |  2017 | 2018   |  2019 |
+-------+-------+--------+-------+
| xxx   |   xxxx| xxxx   | xxxxx |
+-------+-------+--------+-------+

The year and xxx are value entered by the customer. To add a year he has to click on a button, and the xxx are TextBox input where he can edit it anytime. So the I have no idea how many year and value I will get.

My pseudo code look a bit like:

I have Almost every tools to do this. I just can figured out, how to set the new grid as a content of the TabItem, since the TabItem is the Type of my collection's content

Upvotes: 0

Views: 72

Answers (0)

Related Questions