I want to fill all cells with the same control. What I have now is a control template and a grid. But I can’t find a simple way in Xaml to add the control to all the cells.
This is the code I have right now:
<Window x:Class="AcMidi.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="512" Width="760">
<Window.Resources>
<ControlTemplate x:Key="Planet">
<Button Content="Button"></Button>
</ControlTemplate>
</Window.Resources>
<Grid Height="209" Name="grid1" Width="500">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
</Grid>
</Window>
You could use an
ItemsControlItemsSourceto a collection of items which have properties for row postion and column position, you can easily create such a collection with two for loops.ItemsPaneltheGridItemContainerStyleyou can bind theGrid.ColumnandGrid.Rowto the properties on your items.ItemTemplateto your template (which should be aDataTemplateas you are not templating a control).