Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
781
XamGrid Custom XamComboEditorColumn
posted

Hi,

i wrote my own XamGrid column with a XamComboEditor in it. I would like to set the width of the column to the maximum width of the XamComboEditor elements. How can i achieve this goal? The width of ComboEditorItem.Control is always 0.

 

Thanks

Parents
  • 40030
    Offline posted

    Hi, 

    So, the XamComboEditor virtualizes its contents, so first, most elements within it won't have a width. Also, controls will only be assigned to items once the dropdown is assigned, and they won't have sizes during that time. Also, you wouldn't check the width property of the control, you'd check the actualWidth. 

    The main problem is, that you can't be sure that you're calculating the actual width of the max item. Perhaps you could walk through the itemsSource, and find the length of the item. 

    You might be able to dot hat with a TextBlock and as you're looping through your data, set the Text property of the TExtBlock, and check its ActualWidth
    TextBlock tb = new TextBlock() { Text = "abc" };

    width = Math.Max(width, tb.ActualWidth);

    -SteveZ 

Reply Children
No Data