Hello,
I wan't to customize the header and Tabheader of a igDock;ContentPane to a binding source.After my search i solved the Problem for the header, (make HeaderTemplate; bind it to an invisible Textbox and bind the Textbox with code to my object).
But for the TabHeaderTemplate it doesn't work....
Is there a bug? or where is the failure?
For example:
<igDock:ContentPane.HeaderTemplate> <DataTemplate> <TextBlock Text="{Binding ElementName=myHeader, Path=Text}" /> </DataTemplate> </igDock:ContentPane.HeaderTemplate> <igDock:ContentPane.TabHeaderTemplate> <DataTemplate> <WrapPanel> <TextBlock Text="xy" /> <TextBlock Text="{Binding ElementName=myHeader, Path=Text}" /> </WrapPanel> </DataTemplate> </igDock:ContentPane.TabHeaderTemplate> <igDock:ContentPane.Content> <Grid> <TextBlock x:Name="myHeader" Visibility="Hidden" /> </Grid> </igDock:ContentPane.Content>
------- c# behind
Binding b = new Binding("Name");b.Source = myHeaderNode;myHeader.SetBinding (TextBlock.TextProperty ,b);
#########
This works fine for the header, but the tabheader always raise "Cannot find source for binding with reference 'ElementName=myHeader'"
with greetings from germany
Thomas
I'm actually surprised that the ElementName binding within the HeaderTemplate is working given that a DataTemplate/ControlTemplate are namescopes and the names are really only relevant to that namescope. I'm guessing WPF does some fallback and walks up the element tree checking the containing namescopes and since the HeaderTemplate is used by the PaneHeaderPresenter and that is used within the ContentPane it is able to find it. Well the TabHeaderTemplate is not within the ContentPane. It is used by the PaneTabItem that is used to represent the tab item for the ContentPane when it is hosted in a TabGroupPane or UnpinnedTabArea. For that you'll likely need to not use an ElementName binding. If you need to access something on the ContentPane then you should do a FindAncestor binding for the PaneTabItem and then access (via the path) the Pane property of that tab (and whatever property off that you need to access).
Hello again,
thanks to their answer I could expand my knowledge of the binding and find a solution for the problem. This looks as follows:
<igDock:ContentPane.HeaderTemplate> <DataTemplate> <TextBlock Text="{Binding Path=DataContext.Name, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDock:ContentPane}}}" /> </DataTemplate> </igDock:ContentPane.HeaderTemplate> <igDock:ContentPane.TabHeaderTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Pane.DataContext.Name, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDock:PaneTabItem}}}" /> </DataTemplate> </igDock:ContentPane.TabHeaderTemplate>
----- c# behindthis.DataContext = myHeaderNode;
but a small problem still exists, if the pane is floating, the header of the window have no text... the pane-title and the panetabitem-title works fine.Is there a way to set them like the TabHeaderTemplate? I found no Template for the windows caption.