Hello,
we have a problem with the headertemplate of the contentpane in a DockManager. I've tried several binding paths and ancestortypes. But none of them worked. The vs2010 output let me know:
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=(0); DataItem='ContentPane' (Name=''); target element is 'PaneToolWindow' (Name=''); target property is 'Title' (type 'String').
The message is clear to me, but I don't know how to get the correct datacontext. My current, non-working solution is:
<DataTemplate x:Key="headerTemplate"> <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, Mode=FindAncestor, AncestorType={x:Type igDock:ContentPane}}, Path=Content.DataContext.DisplayName}"/> </DataTemplate>
<DataTemplate x:Key="headerTemplate"> <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, Mode=FindAncestor, AncestorType={x:Type igDock:ContentPane}}, Path=Content.DataContext.DisplayName}"/>
</DataTemplate>
So my contentview has a DataContext with property DisplayName.
Thanks in advance
Christian
Hello Christian,
Thank you for your post. I have been looking into it, but I cannot be completely sure how your data is organized and how your source is set, so could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Hello Stefan,
I've created a little samplesolution. To keep it simple I've put the ciew directly into the ContentPane. Normally this view would be injected by prism.
In the XamDockManager's regionadapter the datacontext of the contentpane is set to the viewmodel of the view
container.DataContext = view.DataContext;
So the binding expression is a little different. But the Datastrucure is the same. ContentPane => View => ViewModel
Hello Stefan, thanks for your reply.
Maybe my question was not clear enough. The problem is not the TabHeaderTemplate but the HeaderTemplate, which is responsible for the Header of the floating, undocked ContentPanes.
The TabHeaderTemplate worked the way I've implemented it.
Best regards
Here you can read how the Heders of the Floating, Tabbed and Pinned winows work:
http://ko.infragistics.com/community/forums/t/66217.aspx
Hope this helps you.
Hello Stefan, I'm afraid this doesn't solve the problem. Even if I set the header to a TextBlock with a simple string as Text (no bindings), I receive the bindingerror
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=(0); DataItem='ContentPane' (Name=''); target element is 'PaneToolWindow' (Name=''); target property is 'Title' (type 'String')
I've attached a new sample project which demonstrates the problem. First I thought the problem is, that I use UIElements in my template. But as mentioned here, in the case of FloatingWindowCaptionSource="UseContentPaneCaption", the headertemplate will be displayed.
Looking forward for you reply
That binding error is not related to your issue. In this latest snippet you're not actually setting the HeaderTemplate to the DataTemplate that has the FindAncestor binding. But even if it did it would not work. The reason is that floating windows are in their own separate Window so they are not in the visual/logical tree of the window hosting the xamDockManager. If you move your Style for the ContentPane to the app.xaml (and add the setter for the HeaderTemplate) then you will see the contents you want.
The binding error still happens but I think that is a separate issue. I think that is coming up because by default the Title of the PaneToolWindow is bound to the Header of the ContentPane when the ToolWindow is only displaying a single ContentPane or has a single TabGroupPane. If you set the Header (e.g. Header="" ) then the binding expression warning goes away. It is expected that the Header property will be set since that is the default shown in the contentpane's header, the tab header, the pane navigator item and the panetoolwindow title.
Moving the style from the window to the app.xaml solved the problem. My mistake was that I thought FloatingWindowCaptionSource="UseContentPaneCaption" will force the PaneToolWindow to take the headertemplate of the ContentPane ("UseContentPaneCaption").
Thanks for this solution