The key is to use ItemContainerStyle setting Grid.Coulumn and Grid.Row <ItemsControl ItemsSource="{Binding VDItems}" Grid.Row="1" AllowDrop="True" Name="itemsCtlVD" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="White"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid ShowGridLines="False"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="Grid.Column" Value="{Binding ColumnIndex}" /> <Setter Property="Grid.Row" Value="{Binding RowIndex}" /> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate> <Border BorderThickness="0.2" BorderBrush="LightGray" Background="{Binding Background}" > <Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <Label Content="{Binding Data}" FontWeight="Bold" Foreground="{Binding Foreground}"> </Label> </Viewbox> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonUp"> <i:InvokeCommandAction Command="{Binding ClickTradeCommand}" CommandParameter="{Binding .}" ></i:InvokeCommandAction> </i:EventTrigger> </i:Interaction.Triggers> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>
Tuesday, September 22, 2015
Using Grid to layout ItemsControl Items
Subscribe to:
Posts (Atom)