I hope no one has asked this question yet, but I searched and cannot find a mention. Feel free to point me in the right direction if I missed another question that explains this.
I have a WrapPanel with data-bound elements that essentially contain a variable-length icon and text (this is a legend for the chart). I really like that items appear in neat columns when I set ItemWidth to some given value. However, due to the high variability of the text length in each element, I can not easily select a specific value that will work for all cases. That is, in some cases, the text for all elements may be short, so a lower value for ItemWidth would be appropriate. But in other cases, such a small ItemWidth will result in truncated text among some items.
I believe that I can bind ItemWidth to the WrapPanel in some way to extract the width of each item (and find the maximum width, and use it as ItemWidth, etc.), but I cannot do this because of the data binding potential to the wrong thing. As with binding to something that changes when ItemWidth changes, which leads to infinite loops (or at least loops that repeat more time than necessary).
What is the best way to set this so that ItemWidth is as large as necessary to prevent truncation?
EDIT:
I want to keep the function offered by WrapPanel, which allows you to have a variable number of columns of elements, depending on the space allowed for the WrapPanel itself.
skybluecodeflier
source share