0

I created my MVVM Pattern according to this SO Adding controls dynamically in wpf mvvm

My datatemplate looks like this:

    <DataTemplate DataType="{x:Type Product_Configurator:ModelParametersViewModel}">
        <GroupBox Grid.Row="1" x:Name="groupBox" Header="Standard"  >
            <Grid x:Name="grpStandard" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="1*" />
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Content="{Binding AttributeName}" />
                <TextBox Grid.Column="1" Style="{DynamicResource Configurator_Value_Box}" Text="{Binding EvalValue}"/>
            </Grid>
        </GroupBox>
    </DataTemplate>

This is how my view looks like:

MyView but actually I want all the labels and textboxes in the same groupbox. How do I achieve this?

Community
  • 1
  • 1
Ksdmg
  • 397
  • 5
  • 15
  • 1
    simply remove the GroupBox from your DataTemplate and put the ItemsControl with the Collection of Product_Configurator:ModelParametersViewModels in a GroupBox? – blindmeis Nov 18 '16 at 10:34
  • awesome, somehow it was too obvious for me too see it, thanks. Post it as answer so I can mark it! – Ksdmg Nov 18 '16 at 11:04

1 Answers1

1

remove the GroupBox from your DataTemplate and put the ItemsControl with the Collection of Product_Configurator:ModelParametersViewModels in a GroupBox

blindmeis
  • 22,175
  • 7
  • 55
  • 74