I am loading checkboxes as tags from sql table but these checkboxes are oriented verticaly what is really ugly. How do I can orientate them to be horizontal?
I tried to set the setter property to Stretch but it only center these checkboxes into center of the listview and stays vertically.
Anyone who could help?
xaml:
<ListView Name="listCategory" Visibility="Visible" BorderThickness="0" HorizontalAlignment="Left" Margin="114,70,0,0" Width="207" RenderTransformOrigin="0.5,0.5" Height="180" VerticalAlignment="Top">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
CheckBox Content="{Binding tag}" IsChecked="{Binding Checked}" HorizontalAlignment="Center"/>
</DataTemplate>
</ListView.ItemTemplate>
code for listCategory
public void loadCategoryTags()
{
DataTable dt = new DataTable();
using (SqlCommand selectTags = new SqlCommand("select tag from Categories", cs))
{
cs.Open();
using (SqlDataAdapter dataAd = new SqlDataAdapter(selectTags))
{
dt = new DataTable();
dataAd.Fill(dt);
}
cs.Close();
}
dt.Columns.Add(new DataColumn("Checked", typeof(bool)) { DefaultValue = false });
listCategory.ItemsSource = dt.DefaultView;
}