I have a ListView which is binded to an ObservableCollection.
<ListView
ItemsSource="{Binding CollectionOfObjects}"
SelectedItem="{Binding SelctedObj}" Margin="0,0,0,0"
ScrollViewer.VerticalScrollBarVisibility="Visible" BorderBrush="Orange" BorderThickness="1"
ScrollViewer.HorizontalScrollBarVisibility="Visible" FontSize="10"
>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Height" Value="15"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView >
<GridViewColumn DisplayMemberBinding="{Binding Name}" >
<GridViewColumnHeader Content="Name" Command="{Binding SortCommand}" CommandParameter="Name"/>
</GridViewColumn>
<GridViewColumn Header="Color">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Viewbox Margin="0,0,0,0">
<Rectangle Fill="Red" Visibility="Visible"/>
</Viewbox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
For each object in my collection, it should display the name of it and simply a red rectangle on the right hand side.
I dont know why, but when I start the application it only appears the name without any coloured rectangle. Above is a very simplyfied version of my code. All my bindings are working, also others I implemented in ViewBoxes. Does anyone has an idea what the critical point is?
Give the rectangle a height and width.