开发者

Flip a UIElement but preserve text inside from flipping

I think the title is pretty straightfor开发者_如何学运维ward. 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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜