views:

45

answers:

1

I have a separated assembly where I defined several standard UserControls. Some of this are standard toolbars, like this:

<UserControl x:Class="XXX.ToolbarFullMaintenance"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ToolBar
    Style="{DynamicResource ToolbarMainStyle}"
>
/* MY BUTTONS */
</ToolBar>
</UserControl>

now, I would insert this toolbar inside a ToolBarTray on my window. I try to do this:

<ToolBarTray>
  <toolbars:ToolbarFullMaintenance
       Band="1"
       BandIndex="1"
       Name="mainToolbar" />
</ToolBarTray>

but don't work..."mainToolbar" is saw like a UserControl and not like a ToolBar. How can I do?

A: 

You made your ToolBar a child of a custom UserControl and thus ToolBarTray knows nothing about and embedded ToolBar. You can rectify your design by changing the base class of your ToolbarFullMaintenance to ToolBar instead of UserControl like so:

<ToolBar x:Class="XXX.ToolbarFullMaintenance"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         Style="{DynamicResource ToolbarMainStyle}">

     /* MY BUTTONS */

</ToolBar>
wpfwannabe