How to rotate 2D UIElement around a 3D axis (Y)?

后端 未结 1 868
忘掉有多难
忘掉有多难 2021-01-22 12:18

I have a Grid with some content (image, text) and I would like to rotate it around y-axis in 3D space - somehow an animated tilt effect.

Is there an easy wa

1条回答
  •  不知归路
    2021-01-22 12:50

    Using Viewport3D

    3D rotate

    if you are willing to use 3D models and rotations then here is a sample I attempted to for you, I tried to reproduce the expected result, may not be accurate

        
            
                
            
            
                
            
            
                
                    
                        
                            
                        
                    
                
                
                    
                
                
                    
                
                 
                    
                    
                    
                    
                    
                    
                    
                    
                    
                
            
            
                
                    
                
            
            
                
                    
                        
                            
                                
                                    
                                
                            
                        
                    
                
            
        
    

    now you can rotate your model which is the UI host, currently hosting the grid with the image tiles.

    also you can convert same to a style & template for ContentControl with attached properties for rotation and reuse it where you want.

    Using 2D transforms

    a sample for you to achieve 3D transform into grid with normal transformations

    3D rotate via 2D transform

    the key is to convert 3D transform to 2D and apply to grid directly without complex 3D stuff (this sample does not have any converstion) it simply demonstrate a 3D looking grid transformation for your reference.

        
            
                
            
            

    0 讨论(0)
提交回复
热议问题