Flip a UIElement but preserve text inside from flipping

813 Views Asked by At

I think the title is pretty straightforward. I'm using some custom controls. I want to flip the tab header of a custom tab control. I tried a layout transform (ScaleTransform X = -1) to flip horizontally the tab header. But obviously I want the text inside not to be mirrored. I can't find a way so far.

1

There are 1 best solutions below

0
On BEST ANSWER

You can do this by giving the TabItem a HeaderTemplate, and applying a ScaleTransform there also:

<TabControl>
  <TabItem Header="Hello, World!">
    <TabItem.LayoutTransform>
      <ScaleTransform ScaleX="-1" />
    </TabItem.LayoutTransform>
    <TabItem.HeaderTemplate>
      <DataTemplate>
        <ContentPresenter Content="{Binding}">
          <ContentPresenter.LayoutTransform>
            <ScaleTransform ScaleX="-1" />
          </ContentPresenter.LayoutTransform>
        </ContentPresenter>
      </DataTemplate>
    </TabItem.HeaderTemplate>
  </TabItem>
</TabControl>