I've a project where I swapped the ItemsPanelTemplate
from using a StackPanel
thus
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel IsItemsHost="True" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
to using a Canvas
thus
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas IsItemsHost="True" Width="Auto" Height="Auto"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
I'm doing this so that I can lay out the items by their start times on a timeline rather than stacked up against each other. But then I was stuck as to how to set the Canvas.Left
property for each item in the ItemsControl
. The obvious place (I thought) was in the Grid
I use in the ItemTemplate
's DataTemplate
, i.e. somewhere in here:
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Left" VerticalAlignment="Center" Height="10">
<eventBlockVisualization:FGEventUC/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
But this part of the XAML has no reference to the hosting Canvas
. Luckily there is a very similar question in which atsjoo asks "Setting Canvas properties in an ItemsControl DataTemplate" and Arcturus answers explaining the role and use of the ItemContainerStyle
(and LiamV provides a similar answer here), which in my case results in
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding MinutesFromStartOfLogs}"/>
</Style>
</ItemsControl.ItemContainerStyle>
This is all fine editing the XAML by hand but ideally I would like to manipulate these styles and bindings in Expression Blend 4 or Blend for Visual Studio 2012. If I select the ItemsControl
in Blend's 'Objects and Timeline' panel and then go to the menu 'Objects -> Edit Additional Styles -> Edit Generated Item Container (ItemContainerStyle)' I do end up able to edit the ItemContainerStyle but I cannot see where Blend exposes the Canvas.Left
property that is set in my XAML. Where is it? Is this 'Blendable'?