I have a tabcontrol that is populated from an observablecollection. Based on the observablecollection the tabitems headers gets set and datagrid in the tabitem gets populated. What I am trying to do is get the tabitem header and set it in a textblock. I was able to get the tabcontrol name and set it to a textblock text but not the header from the selected tabitem.
<TabControl Grid.Row="1" ItemsSource="{Binding Workspaces}" Height="Auto" Background="Transparent" x:Name="TabsName" >
<TabControl.Resources>
<localHelper:HeaderAppendConverter x:Key="HeaderAppedConvrter"/>
</TabControl.Resources>
<TabControl.ItemTemplate >
<DataTemplate >
<TextBlock Text="{Binding HeaderText}" />
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate x:Name="Tabsitems">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="725" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1600" />
</Grid.ColumnDefinitions>
<dxg:GridControl Grid.Row="1" x:Name="NameGrid" ItemsSource="{Binding Data}" >
<dxgcore:GridControl.Columns>
<dxg:GridColumn Name="Month1" FieldName="Month01" Visible="True" AllowEditing="False" HorizontalHeaderContentAlignment="Center" CellStyle="{StaticResource NumberCellStyle}">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings HorizontalContentAlignment="Right" />
</dxg:GridColumn.EditSettings>
<dxg:GridColumn.Header>
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=SelectedItem.Header, Converter={StaticResource HeaderAppendConverter}, ConverterParameter='01'}" />
</dxg:GridColumn.Header>
</dxg:GridColumn>
</dxg:GridColumn>
</dxgcore:GridControl.Columns>
<dxgcore:GridControl.View>
<dxgcore:TableView x:Name="NameGridView"
AllowEditing="False"
AllowBestFit="True"
AllowMoving="True"
AllowColumnFiltering="True"
IsColumnMenuEnabled="True"
ShowGroupPanel="False"
ShowAutoFilterRow="True"
AutoWidth="False"
NavigationStyle="Cell"
VerticalScrollbarVisibility="Visible"
HorizontalScrollbarVisibility="Visible"
RowStyle="{StaticResource customRowStyle}" >
</dxgcore:TableView>
</dxgcore:GridControl.View>
</dxg:GridControl>
</Grid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
public class WorkSpace : INotifyPropertyChanged
{
private string headerText;
public string HeaderText { get { return headerText; } set { headerText = value; OnPropertyChanged("HeaderText"); } }
public override string ToString()
{
return HeaderText;
}
private List<Data> data;
public List<Data> Data { get { return data; } set { data = value; OnPropertyChanged("Data"); } }
This line
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=Name}" />
sets the tabcontrol name to the textblock How can I change that to get the selected tabitem header text