需要帮助TabControl内容模板更改 [英] Need help with TabControl Content Template changes

查看:112
本文介绍了需要帮助TabControl内容模板更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的TabControl上,我有一个实现Transition模板的内容模板。我想要做的是当选项卡选择为更高(右侧)时使用一个模板,当选项卡位于当前所选选项卡的下部(左侧)时使用另一个模板。这是为了让它看起来更像是在书中翻页。你翻转一个方向前进,另一个方向返回。



我准备好了翻译我只需要弄清楚它们之间是如何正确切换的。以下是一个可能的起点。如果这可能是资源字典中使用的
并且没有绑定到特定的TabControl,那将会是非常精彩的。我不知道触发器是否是正确的方法。



On my TabControl I have a Content Template that implements a Transition template. What I would like to do is have one template be used when the tab selected is 'higher' (to the right) and a different one when the tab is lower (to the left) of the current selected tab. This is to make it look more like flipping pages in a book. You flip one way to go forward and another to go back.

I have the translations ready I just need to figure out how switch between them correctly. Below is a possible starting point. What would be extremely wonderful would be if this could
used in the Resource Dictionary and not tied to a specific TabControl. I don't know if a trigger is the right way to go.

<TabControl.ItemContainerStyle>
            <Style TargetType="TabItem">
                <!--set the content template in setter first-->
                <Setter Property="ContentTemplate" Value="{StaticResource TabTemplateRotateLeft}" />
                <Style.Triggers>
                    <!--use data trigger to switch the content template-->
                    <DataTrigger Binding="{Binding}" Value="All" >
                        <Setter Property="ContentTemplate" Value="{StaticResource TabTemplateRotateRight}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TabControl.ItemContainerStyle>







任何帮助将不胜感激。我仍然是WPF的新手,我知道很多事情都是可能的但不知道怎么做。




Any help would be appreciated. I'm still pretty new to WPF and I know many things are possible but not how to do them.

推荐答案

使用ValueConverter可能更容易。至少它更容易被人嘲笑。有关使用IValueConverter的信息,请尝试以下文章:Data-Binding-Using-IValueConverter-in-Silverlight 在Silverlight中使用IValueConverter进行数据绑定 [ ^ ]
It might be easier to use a ValueConverter. At least it is easier to bebug. For information on using IValueConverter, try this article: Data-Binding-Using-IValueConverter-in-SilverlightData Binding Using IValueConverter in Silverlight[^]


这篇关于需要帮助TabControl内容模板更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆