WPF - 基于扩展器IsExpanded隐藏/显示图像

时间:2016-12-12 11:36:19

标签: c# wpf expander

如果展开器折叠,我想显示图像,并在展开时隐藏它。我尝试了以下但它不起作用。有没有办法在不使用转换器的情况下这样做?

<Image x:Name="fgImage" Source="Resources/Images/MissingImage.png" Margin="0,96,258,-75" Height="110" VerticalAlignment="Top" HorizontalAlignment="Right" Width="110">
 <Image.Style>
  <Style TargetType="Image">
   <Setter Property="Visibility" Value="Visible"/>
    <Style.Triggers>
     <DataTrigger Binding="{Binding ElementName=orderDetailsExpander, Path=IsExpanded}">
      <Setter Property="Visibility" Value="Collapsed"/>
     </DataTrigger>
    </Style.Triggers>
   </Style>
  </Image.Style>
 </Image>

2 个答案:

答案 0 :(得分:1)

您的DataTrigger需要一个值,例如

/*  // Creates a FileReader Object
  FileReader fr = new FileReader(file); 
  char [] a = new char[50];
  fr.read(a);   // reads the content to the array

  for(char c : a)
     System.out.print(c);   // prints the characters one by one
  fr.close(); */
  }
  import java.util.Scanner;
  import java.io.*;
  public class Test{
  public static void main(String args[]){
    System.out.println("Enter 1 to Add Books:");
    System.out.println("Enter 2 to Check Store Books again in Variable:");
    Scanner input=new Scanner(System.in);
    int i=input.nextInt();
    if(i==1){
        System.out.println("You Press B");
        Filewriting fw=new Filewriting();
        fw.filewriting();
    }
    if(i==2)
    {
         Filewriting fw=new Filewriting();
         AddBook obj=new AddBook(fw.add);
         for ( int j = 0; j < 2; j++) // for storing 2 variables data
      {
      System.out.println(obj.bookname[j]); // just check bookname,shows null
       }
     }
// Please write code that we read the file as well as data is stored again in Variables     

    }
    }

根据documentation,默认值为Value="True"

答案 1 :(得分:1)

您的def create_tmp_table(*varargs): name = raw_input('Scegli un nome per la tabella d\'appoggio') query = """ CREATE TABLE {0} ( SOME COLUMNS ); """.format(name) varargs[0].execute(query) varargs[1].commit() 必须像那样

DataTrigger

所有<DataTrigger Binding="{Binding ElementName=orderDetailsExpander, Path=IsExpanded}" Value="True"> 属性

Image