I have the following ItemsControl that I use to display a collection of viewModels.
<Border>
<ItemsControl ItemsSource="{Binding MyViewModel.MyCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="20"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl Content="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
And the code behind is:
MyCollection = new ObservableCollection<ViewModel>();
foreach(var model in MyModelList)
{
var myViewModel = new ViewModel(model);
MyCollection.Add(myViewModel);
}
Now this works fine. BUT now I want to not have an ItemsControl because there are only ever two items that are going to be added to MyCollection ObservableCollection.
I want to add each of the two viewModels into their own column in a single row datagrid in order to display the grid columns differently. (For example when user clicks on one viewModel I want to change the datagird background for only that column)
How do I modify the above to do this?