SimonC
SimonC

Reputation: 1617

Use Style from Application in External Controls

How can I use my application's styling on controls in a different project?

I have a VS solution with three projects; AndroidLib, the actual application and a library with custom controls for the application.

The application is styled with MahApps.Metro 14.0.0. I'd like to use this style with the controls from my control lib. However, whenever I add a custom control, the styles are the default. When, however, I use the controls provided with WPF, the styles go back to MahApps.Metro.

Example:

<TabControl Margin="200, 30, 0, 0" >
        <TabItem x:Name="testListViewItem" Header="Test TabItem" />
</TabControl>

This works and uses the MahApps.Metro styling. However:

<TabControl Margin="200, 30, 0, 0" >
        <dmailControls:EmailListViewTabItem x:Name="testListViewItem" Header="Test TabItem" />
</TabControl>

Shows, but it doesn't assume the styling from MahApps.Metro.

Upvotes: 0

Views: 170

Answers (1)

punker76
punker76

Reputation: 14611

If you mean the style for the EmailListViewTabItem than maybe you forgot to set the MahApps style for it.

You should use this at App.xaml to get the style for your custom TabItem.

<Style TargetType="{x:Type dmailControls:EmailListViewTabItem}"
       BasedOn="{StaticResource MetroTabItem}" />

Hope this helps.

Upvotes: 2

Related Questions