Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding multiple objects to a listview

$
0
0

Hello,

I'm trying to bind some text to a textblock, but also add in some separators to divide some sections.

Xaml:

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><TextBlock FontSize="50" Background="White"/>

<ListView Grid.Row="2" BorderBrush="White" Name="ListView1" ItemsSource="{Binding Path=Line}" HorizontalAlignment="Stretch" FontSize="23"><ListView.ItemTemplate><DataTemplate><StackPanel><TextBlock Text= "{Binding Path = aline}"/></StackPanel> </DataTemplate></ListView.ItemTemplate></ListView ></StackPanel>

This Xaml is being loaded in during runtime, so the binding is also done in code behind.

The binding to the textblock is working as intended, but I can't seem to figure out a way to insert a separator. I've tried to Listview.Items.add(mySeparator), but I get the error message saying that the listview is in use.

I've also tried to create a new ListView, then adding in the separator, then adding in the binding, but I get an error message saying that the Items need to be cleared before binding.

Any suggestions or different paths I can take?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>