Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Binding in ContentPane.TabHeaderTemplate doesn't work
posted

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

Parents
  • 54937
    Verified Answer
    Offline posted

    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).

Reply Children