-1

I have property ObservableCollection in my ViewModel and in View I want to charge that property throw the DataGrid. I want to do that with button. Can anybody Help me? My property has Name and Value and both of them are strings.

public ObservableCollection<Parameter> EnviromentVariables
{
    get;
}

XAML code:

<GroupBox Header="Enviroment Variables" Width="250" Margin="10" VerticalAlignment="Top">
    <DataGrid ItemsSource="{Binding EnviromentVariables}"  CanUserAddRows="True" Height="150" IsReadOnly="False" Margin="10">
        <DataGrid.Columns>
            <DataGridTemplateColumn>
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Button Content="+" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
</GroupBox>
Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62

1 Answers1

0

you could bind the button click command with a ICommand into your VM.

there is another post wiht more details: WPF ICommand MVVM implementation