Jader Dias
Jader Dias

Reputation: 90583

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

I use a TabControl Each tab has its default button. The first default button is working. The second default button is a normal button. How to fix that?

Upvotes: 1

Views: 1198

Answers (1)

Botz3000
Botz3000

Reputation: 39650

You could bind each Button's IsDefault property to its corresponding TabItem's IsSelected Property. 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 ... -->

Upvotes: 11

Related Questions