I am developing silverlight 4 application. I am using the following listbox for dynamic binding
<ListBox Margin="44,100,46,138" x:Name="lstbox1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding A1}" Foreground="Gray" FontSize="14" Width="100" Height="20" ></TextBlock>
<TextBlock Text="{Binding A2}" Foreground="Red" Width="100" Height="20" ></TextBlock>
<Line X1="-3400" Y1="32" X2="10" Y2="32" Stroke="Gray" StrokeThickness="1"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I am using the following code in code behind
List<Data1> ObserCollObj = new List<Data1>();
public MainPage()
{
InitializeComponent();
Data1 obj1 = new Data1("aaa", "dasd");
ObserCollObj.Add(obj1);
lstbox1.ItemsSource = ObserCollObj;
}
I am using the following class
class Data1
{
public String A1 { get; set;}
public String A2 { get; set; }
public Data1()
{
}
public Data1(String a1, String a2)
{
A1 = a1;
A2 = a2;
}
}
I am using all above code but the dynamic binding does not working.Is anything wrong in my xaml or code behind ? Can you please tell me where I am going wrong ? Can you please provide me any solution through which I can resolve the above issue?