For a very custom calendar control, I need to have a week object and bind the Day objects within that week to a grid. I figured I would have the DayOfWeek enum decide where the day should go within the grid. That way if the month starts on a Tuesday it'll have the property Grid.Column="2". But for some reason all of them end up in the first column and I don't know why.
<ItemsControl ItemsSource="{Binding Weeks}" SnapsToDevicePixels="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Days}"> <!--7 most of the time-->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="28" />
<ColumnDefinition Width="28" />
<ColumnDefinition Width="28" />
<ColumnDefinition Width="28" />
<ColumnDefinition Width="28" />
<ColumnDefinition Width="28" />
<ColumnDefinition Width="28" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Date.Day}" Grid.Column="{Binding DayOfWeekInt}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
And I have that binding to a property on the day object like so:
public int DayOfWeekInt
{
get { return (int)Date.DayOfWeek; }
}
Any Ideas?