我想扩展选项卡控件以具有可关闭的选项卡项.
我找到了Kent的这个WPF解决方案:
On the WPF TabControl – can I add content next to the tab headers?
我在Blend中打开了现有silverlight tabcontrol的副本.但是,该结构与WPF tabcontrol看起来完全不同.我无法直接进入Silverlight控件模板.
有谁知道我的好资源?
解决方法
您可以使用Template TabItem来设置某种关闭按钮,您可以在后面的代码中挂钩以关闭当前选定的选项卡.
<Style targettype="TabItem"> <Setter.Value> <ControlTemplate targettype="sdk:TabItem"> <Button x:Name="PART_btnClose" Height="15" Width="15" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="20,3,8" BorderThickness="1" Cursor="Hand" /> </ControlTemplate> </Setter.Value> </Style>
在此之后,在应用模板上,您可以订阅ButtonClicked事件.
像这样的东西:
public override void OnApplyTemplate() { base.OnApplyTemplate(); PART_btnClose = GetTemplateChild("PART_btnClose") as Button; if (PART_btnClose != null) { PART_btnClose.Click += new RoutedEventHandler(PART_btnClose_Click); }
Ty Rozak
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。