JerryBaxia
JerryBaxia

Reputation: 113

WPF:How to Interaction.Triggers Add Where

  <StackPanel>
      <TextBox Text="" x:Name="input"/>
      <Button Content="Click">
          <i:Interaction.Triggers>
              <i:EventTrigger EventName="Click"><!-- TextBox has to contain "ABC" to get Button Click enabled this event-->
                  <i:InvokeCommandAction Command="{Binding OnAdd}" CommandParameter="1"></i:InvokeCommandAction>
              </i:EventTrigger>
              <i:EventTrigger EventName="Click"><!-- TextBox has to contain "123" to get Button Click enabled this event-->
                   <i:InvokeCommandAction Command="{Binding OnAdd2}" CommandParameter="1"></i:InvokeCommandAction>
               </i:EventTrigger>

          </i:Interaction.Triggers>
      </Button>
  </StackPanel>

I want the <i:EventTrigger EventName="Click"> TextBox has to contain "ABC" to get Button Click enabled this event

Upvotes: 0

Views: 711

Answers (1)

Mohnkuchenzentrale
Mohnkuchenzentrale

Reputation: 5885

I would suggest you do this handling within your OnAdd Command. Look especially for the CanExecute Method. This one handles if you Button will be enabled or not. You can read here how to implement this :

Commands Tutorial

Upvotes: 1

Related Questions