Hello all,
I was wondering if you could help me out. I am trying to convert
<DataGrid x:Name="testdatagrid" ItemsSource="{Binding TestDataVM, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" AutoGenerateColumns="True" Margin="0,0,429,146"/>
and set the itemssource of my testdatagrid programmatically to a dataset to be able to switch between tables on the click of a button.
I have managed to set the itemssource with the following code:
testdatagrid.Itemssource = TestDataVM.TestDataset.Tables("test").defaultview
but I would like to set the mode to twoway to have the datagrid refresh automatically and also set the Updatesourcetrigger to property changed.
I could not find what I was looking for online. I tried creating a new binding and setting the mode and updatesourcetrigger
Dim b as New Binding
b.mode = mode.twoway
....
testdatagrid.setbinding(testdatagrid.Itemssource, b)
but that did not work. Does anyone here have an idea of how I could set the mode and sourcetrigger programmatically? Maybe I am doing something fundamentally wrong here?