wpf data trigger command [duplicate]

2019-09-08 15:05发布

问题:

This question already has an answer here:

  • Wpf button data trigger 1 answer
  • wpf button command binding after trigger the propery changes 1 answer

In this below code when button is pressed AddAttachmentCommand working properly and then button text is changed to Approve, My requirement is i want to click that Approve button and want to find the new command isapprovetemplatecommand...

  <Button ToolTip="Attach file" 
                        Height="25" 
                        Command="{Binding AddAttachmentCommand}" 
                        Margin="5,10,5,10">

                    <Button.Style>
                        <Style TargetType="{x:Type Button}">
                            <!-- Default Content value -->
                            <Setter Property="Content">
                                <Setter.Value>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="/UILibrary;component/Themes/Default/Images/Attach.PNG"/>
                                    </StackPanel>
                                </Setter.Value>
                            </Setter>

                            <!-- Triggered values -->
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsAttachmentAvailable}" Value="True">
                                    <Setter Property="Visibility" Value="Visible"/>
                                    <Setter Property="Content" Value="Appprove"/>
                                    <Setter Property="Command" Value="{Binding isapprovetemplatecommand}"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsAttachmentAvailable}" Value="False">
                                    <Setter Property="Visibility" Value="Visible"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsAttachmentAvailable}" Value="False">
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>
标签: c# wpf xaml mvvm