WrapPanel: Trying to make the ItemWidth equal to the max width of any one element

后端 未结 3 535
情话喂你
情话喂你 2021-01-12 07:01

Hopefully no one else has already asked this question, but I have searched and cannot find any mention. Feel free to point me in the right direction if I missed another que

3条回答
  •  醉梦人生
    2021-01-12 07:28

    You could wrap each item in a Grid, and use the Grid's ShareSizeScope property to make sure all items share the same width.

    For example, on your WrapPanel you would set Grid.IsSharedSizeScope to true

    
    

    Then you'd wrap each item in a single cell Grid that uses the SharedSizeGroup property to tell them that they all share a size

    
        
            
        
        
    
    

    If you want an example, a quick Google search gave me this answer which contains a code example.

    I'd recommend performance testing this too if you have a large set of data.

提交回复
热议问题