test.Add(new DataPoint(Brushes.Black));
<Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <ListBox Name="list"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Rectangle x:Name="Robot" Fill="{Binding ColorName}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
public class DataPoint { public DataPoint(SolidColorBrush name) { ColorName = name; } public SolidColorBrush ColorName { get; set; } }
public MainWindow() { InitializeComponent(); List<DataPoint> test = new List<DataPoint>(); test.Add(new DataPoint(Brushes.Red)); test.Add(new DataPoint(Brushes.Black)); list.ItemsSource = test; }
Grid
Grid.Row
Grid.Column
SetRow
SetColumn
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)