Reuse path object in XAML

后端 未结 6 714
醉话见心
醉话见心 2021-01-04 05:46

I have a Path (a star figure):



        
6条回答
  •  日久生厌
    2021-01-04 06:12

    In a related note, (although probably not directly answering your question), you can also declare a FrameworkElement as a Resource, give it a key, and as long as you add x:Shared="False" you can access the resource again and again in code.

    Here's a pseudocoded example:

    
       
          
             
                
             
          
       
       
    
    

    Then, in code, you can access the resourced shape and reuse it as many times as needed.

    Ellipse tempRect = (Ellipse)FindResouce("ReusableEllipse");
    

提交回复
热议问题