Reputation: 3442
I have two buttons. How I can enable second button after clicking on first button using only xaml.
<Window.Resources>
<Style x:Key="NewButtonStyle" TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SecondButton, Path=IsEnabled,Mode=TwoWay}" Value="True">
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button x:Name="FirstButton" Content="Button" HorizontalAlignment="Left" Margin="10,22,0,0" VerticalAlignment="Top" Width="75" Style="{StaticResource NewButtonStyle}"/>
<Button x:Name="SecondButton" Content="Button" HorizontalAlignment="Left" Margin="105,22,0,0" VerticalAlignment="Top" Width="75" IsEnabled="False"/>
</Grid>
Upvotes: 1
Views: 439
Reputation: 791
You have to add two references in order to use Interaction.Triggers and ChangePropertyAction (System.Windows.Interactivity and Microsoft.Expression.Interactions)
<Button x:Name="FirstButton" Content="Button" HorizontalAlignment="Left" Margin="10,22,0,0" VerticalAlignment="Top" Width="75">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:ChangePropertyAction TargetName="SecondButton" PropertyName="IsEnabled" Value="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button x:Name="SecondButton" Content="Button" HorizontalAlignment="Left" Margin="105,22,0,0" VerticalAlignment="Top" Width="75" IsEnabled="False"/>
Upvotes: 1