1
votes

Im trying to make an event trigger using a button to tell the ListView each time to resize it columns automatically.

ive used different methods but non of them worked, the event is in this code defined inside the ListView and im trying through DataBinding to take the action (IsPressed) from the Button trigger the ListView.

when i try to execute the code i get the following error The tag 'Binding' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

im doing the DataBinding in a wrong way? will this code in this way work at all? thanks in advance!

  <ListView.Style>
      <Style>
          <Style.Triggers>
              <Trigger  Binding = "{Binding ElementName=Button1,Path=IsPressed}"  Value="True">               
                  <Setter   Property="GridViewColumn.Width" Value="Auto"/>                          
              </Trigger>
          </Style.Triggers>    
      </Style>
  </ListView.Style>
2
Hi, any chance you could post less code, ideally only the lines of XAML you are having issues with, thanks.JMK

2 Answers

2
votes

To bind a Trigger to a property outside the element scope use DataTrigger

Example:

<DataTrigger Binding="{Binding ElementName=Button1, Path=IsPressed}" Value="True">
   <Setter Property="GridViewColumn.Width" Value="Auto"/>                          
</DataTrigger>
0
votes

A regular trigger(Property Trigger) only responds to dependency properties, which you are trying as of now:

<Style.Triggers>
  <Trigger  .....

Use DataTrigger, it can be bound to another control

<Style.Triggers>
  <DataTrigger Binding="{Binding