TabItem used in own module

Mar 21, 2010 at 1:04 PM

Hi,

I'm busy porting my application to use Calcium and proper MVVM practices. I've run into some troubles, and maybe I can get some advice here.

I've got a simple GUI that contains two TabItems in a TabControl:

 

<TabControl>
   <TabItem Header="Groups">
...
   </TabItem>
</TabControl>

 

However, they do not display correctly: the specified header is not shown and the Output displays:

 

System.Windows.Data Error: 39 : BindingExpression path error: 'ViewModel' property not found on 'object' ''MainViewModel' (HashCode=25337316)'. BindingExpression:Path=ViewModel; DataItem='MainViewModel' (HashCode=25337316); target element is 'TabItem' (Name=''); target property is 'Header' (type 'Object')

 

After some digging I found that Calcium's theme applies a Style to all TabItem's:

 

	<Style TargetType="{x:Type TabItem}">
		<Setter Property="Header" Value="{Binding ViewModel}" />
		<Setter Property="HeaderTemplate" Value="{DynamicResource TabHeaderDataTemplate}" />
...

 

It seems to me this style (specifically the binding of the Header) is only correct for the TabItems that are used for Calcium modules.

Is there a work-around? Or is there some reason a TabItem can only be used for a module?

Bye,

Steven

PS: I hope this displays properly. My previous post got messed up and there is no preview.

Coordinator
Mar 21, 2010 at 11:58 PM

Hi Steven,

Yes, there is an implicit style on the TabItem as you've discovered. I will copy this to a work item, and make a new region adapter to apply an explicit style. For the meantime you could set the style on your TabItems to Style="{x:Null}" or to a named style.

Cheers,

Daniel

Coordinator
Mar 21, 2010 at 11:59 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.