my listview will display only the item that its added by the constructor and it wont add the items that i add dynamically
public class PostList : ObservableCollection<PostData>
{
public PostList()
: base()
{
Add(new PostData("Isak", "Dinesen"));
// Add(new PostData("Victor", "Hugo"));
// Add(new PostData("Jules", "Verne"));
}
public void AddToList (string[] data){
string username2, msg;
msg = data[0];
username2 = data[1];
Add(new PostData(msg, username2));
}
}
public class PostData
{
private string Username;
private string Msg;
private string Avatar;
private string LinkAttached;
private string PicAttached;
private string VideoAttached;
public PostData(string msg ,string username, string avatar=null, string link=null,string pic=null ,string video=null)
{
this.Username = username;
this.Msg = msg;
this.Avatar = avatar;
this.LinkAttached = link;
this.PicAttached = pic;
this.VideoAttached = video;
}
public string pMsg
{
get { return Msg; }
set { Msg = value; }
}
public string pUsername
{
get { return Username; }
set { Username = value; }
}
.....
.....
}
Xaml
<ListView x:Name="PostListView" BorderThickness="0"
MinHeight="300"
Background="{x:Null}"
BorderBrush="{x:Null}"
Foreground="{x:Null}"
VerticalContentAlignment="Top"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled" IsSynchronizedWithCurrentItem="True"
MinWidth="332" SelectedIndex="0" SelectionMode="Extended" AlternationCount="1" ItemsSource="{Binding Source={StaticResource PostListData}}">
<ListView.ItemTemplate>
<DataTemplate>
<DockPanel x:Name="SinglePost" VerticalAlignment="Top" ScrollViewer.CanContentScroll="True" ClipToBounds="True" Width="333" Height="70" d:LayoutOverrides="VerticalAlignment" d:IsEffectDisabled="True">
<StackPanel x:Name="AvatarNickHolder" Width="60">
<Label x:Name="Nick" HorizontalAlignment="Center" Margin="5,0" VerticalAlignment="Top" Height="15" Content="{Binding Path=pUsername}" FontFamily="Arial" FontSize="10.667" Padding="5,0"/>
<Image x:Name="Avatar" HorizontalAlignment="Center" Margin="5,0,5,5" VerticalAlignment="Top" Width="50" Height="50" IsHitTestVisible="False" Source="1045443356IMG_0972.jpg" Stretch="UniformToFill"/>
</StackPanel>
<TextBlock x:Name="userPostText" Margin="0,0,5,0" VerticalAlignment="Center" FontSize="10.667" Text="{Binding Path=pMsg}" TextWrapping="Wrap"/>
</DockPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>