简体   繁体   English

WPF中的每个选项卡都可以有一个默认按钮吗?

[英]Is it possible to have a default button for each tab in WPF?

I use a TabControl Each tab has its default button. 我使用TabControl每个选项卡都有其默认按钮。 The first default button is working. 第一个默认按钮正在工作。 The second default button is a normal button. 第二个默认按钮是普通按钮。 How to fix that? 如何解决?

You could bind each Button's IsDefault property to its corresponding TabItem's IsSelected Property. 您可以将每个Button的IsDefault属性绑定到其对应的TabItem的IsSelected属性。 Each time the selected tab item changes, another button would become the default, then. 每次选定的选项卡项目更改时,另一个按钮将成为默认按钮。

Something like that: 像这样:

<TabControl>
  <TabItem x:Name="tab1" ... />
  <!-- ... other tabs ... -->
</TabControl>
<Button x:Name="button1" IsDefault="{Binding IsSelected, ElementName=tab1}"/>
<!-- ... other buttons ... -->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM