How to use VisualState AdaptiveTrigger to change ListView Item FontSize

后端 未结 2 1428
温柔的废话
温柔的废话 2021-01-07 01:20

I am using Visual State Adaptive Trigger to change page appearance depending on effective screen resolution. This works great, but I cannot get it to work for ListView Items

2条回答
  •  醉话见心
    2021-01-07 01:32

    We can't use AdaptiveTrigger for an element inside the DataTemplate. You should use UserControl to do it. This answer may help you. If you want a video tutorial then this video may help you. But I have a little workaround for it.

    Here is my method:

    1. Create a TextBlock outside the DataTemplateand set Visibility="Collapsed"

      
      

      Note: You could also use BindableValueHolder instead of this and set the Value property of it using AdaptiveTrigger.

      
      
    2. Use AdaptiveTrigger to change the FontSize of this TextBlock

      
          
              
                  
                      
                  
                  
                      
                  
              
          
      
          
              
                  
                      
                  
                  
                      
                  
              
          
      
      
    3. DataBind the FontSize of the TextBlock inside the DataTemplate to the outer TextBlock

      
      

    Here is your code:

    
        
            
                
                
                    
                
                
                    
                
            
        
    
        
            
                
                
                    
                
                
                    
                
            
        
    
    
    
    
        
            
                
            
        
    
    

提交回复
热议问题