The program has a ListBox , the elements of which have the following structure:

  <ListBox.ItemTemplate > <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="18" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="23" /> </Grid.ColumnDefinitions> <Image ToolTip="Видимость" Margin="5,0,5,0" Grid.Column="0"> <Image.Style> <Style TargetType="{x:Type Image}"> <Setter Property="Source" Value="{Binding Path=View, Converter={StaticResource ResourceKey=FactViewConverter} }"> </Setter> </Style> </Image.Style> </Image> <TextBlock Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="1"/> <Button x:Name="BtnVis" Grid.Column="2" CommandParameter="{Binding}" Command="{Binding Path=DataContext.FactVisibleCommand, ElementName=lstFacts}" Style="{StaticResource ButtonFilter }" Margin="0,0,13,0"> <Button.Template> <ControlTemplate> <Image ToolTip="Видимость" Margin="0"> <Image.Style> <Style TargetType="{x:Type Image}"> <Setter Property="Source" Value="{Binding Path=IsVisible, Converter={StaticResource ResourceKey=VisibleImageConverter} }"> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Source" Value="../Images/invis.png"/> </Trigger> </Style.Triggers> </Style> </Image.Style> </Image> </ControlTemplate> </Button.Template> </Button> </Grid> </DataTemplate> </ListBox.ItemTemplate> 

The button has an image that changes with the converter when pressed.

But a similar action caused by pressing the button occurs in other actions (via the context menu of the column headings of the table). Is it possible to somehow cause a change in the image of a button when calling another method?

  • Advice for the future: add the tag of the programming language used - C# , F# , ... this will draw more attention to the question -> the probability of getting an answer will increase. - Ev_Hyper
  • The question is not clear ... better create an MCVE or describe the problem in more detail. - Ev_Hyper
  • Well, if you do not want a converter, you can add a DataTrigger to the desired condition. May have to move the trigger to the style, not sure. - VladD

0