I'm new to C #. I would like to know how to create a grid list that contains images, something similar to what android has:
Thank you in advance.
I'm new to C #. I would like to know how to create a grid list that contains images, something similar to what android has:
Thank you in advance.
Content must be placed within ItemsControl
like this:
<ItemsControl
ItemsSource="{Binding Tasks, UpdateSourceTrigger=PropertyChanged}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"
AllowDrop="True"
Width="{Binding ActualWidth, ElementName=itmWrapPanel}"
Height="{Binding ActualHeight, ElementName=itmWrapPanel}" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate >
<local:ucTask /> <!-- esse ucTask é um usercontrol com o que será exibido -->
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
ucTask
<UserControl x:Class="blablabla.ucTask"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid Focusable="False" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,5">
<Image Source="{Binding Imagem}" Focusable="False"/>
</Grid>
<Grid Grid.Row="1" HorizontalAlignment="Center">
<Label Content="{Binding Texto}" FontSize="10"/>
</Grid>
</Grid>
</UserControl>
Q: Positioning and / or alignment customizations are not in this example, and are on your own.
P.S.2: The WrapPanel
is to distribute the items in its ItemsControl
the alignment and positioning should be checking on it tb