'Dynamic Groupbox with Datagrid can't resize columns

Hi I've got a problem with my program. I generate several groupboxes which contain buttons and a datagrid. To adjust the size of the groupboxes automaticly to the windowsize I deleted the width attribute from my groupbox. Now the Datagrid in the groupbox has some weird behavior. The columns are minimized and I can't adjust them anymore.

GroupBox groupbox = new GroupBox();
        groupbox.Header = deviceName;
        groupbox.Name = deviceName;
        //groupbox.Margin = new Thickness(10);
        //groupbox.Width = 850;
        groupbox.Height = 250;

Datagrid without the width attribute of the groupbox

Datagrid with the width attribute of the groupbox



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source