I use the Mahapps Metro theme in my project. I want to create TabControl
where the TabItem
image will be. The Mahapps theme provides TabItem text color change when selected TabItem
, etc. I want to bind this foreground color to my image. I have a solution to this problem, but I think this is not true.
Bad code (but it works):
<TabItem>
<TabItem.HeaderTemplate>
<DataTemplate>
<Grid Margin="0,5,0,0">
<TextBlock x:Name="myTextBlock" />
<Rectangle Width="28.947" Height="25" Fill="{Binding ElementName=myTextBlock, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_image_gallery}" />
</Rectangle.OpacityMask>
</Rectangle>
</Grid>
</DataTemplate>
</TabItem.HeaderTemplate>
</TabItem>
source
share