עבור לתוכן

ItemsControl - WPF

Featured Replies

פורסם

יש לי טבלה בבסיס נתונים (עם 3 עמודות string,int,int), ואני רוצה להציג אותה על המסך לא בצורת GRID,

אלא- בעיצוב של LABELים וקוים מפרידים.

איך עושים זאת באמצעות ItemsControl?

פורסם

את יכולה ליצור ItemTemplate


<ItemsControl.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=FirstProperty}"/> <TextBlock Text="{Binding Path=SecondProperty}"/> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate>

כש- FirstProperty ו - SecondProperty הם Properties ב- DataContext של הItemsSource של ה- ItemsControl שלך.

זה משהו די בסיסי ב-WPF, כדאי שתעברי על הנושא הזה מהבסיס.

פורסם
  • מחבר

OK.

יצרתי את הITEMCONTROL, ואני רוצה שהSTACKPANEL עם הנתונים יסודר בWARPPANEL (כלומר - כשמתמלא טור , יתחיל טור חדש).

רשמתי:

 <WrapPanel Grid.Row="2" Height="390" HorizontalAlignment="Left" Name="wrapPanel" VerticalAlignment="Top" Width="734" Orientation="Vertical" > <ItemsControl DockPanel.Dock="Top" Name="itemControlGrid" Grid.Row="2" > <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Height="30" Name="stackPanel3" Width="360"> <Grid Height="25" Width="360"> <Grid.ColumnDefinitions> <ColumnDefinition Width="206*" /> <ColumnDefinition Width="65" /> <ColumnDefinition Width="65" /> </Grid.ColumnDefinitions> <Label Content="{Binding Path=SugTeur}" Style="{StaticResource labelStyle}" /> <Label Content="{Binding Path=Count1}" Grid.Column="1" Foreground="#FF2F76C1"/> <Label Content="{Binding Path=Count2}" Grid.Column="2" Foreground="#FFD14848"/> </Grid> Width="352" Height="5"/> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </WrapPanel> 

אבל בפועל אין לי מעבר לטור חדש. מה הבעיה?

(ושאלה להמשך - האם יש אפשרות לצייר קו מפריד בין הטורים? כיצד?)

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים