Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to wpf. I am trying to bind a collection to a listbox which has a label and textboxes inside it.
The xaml code is
XML
<Window.Resources>
        <DataTemplate x:Key="MyDataTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Label Content="{Binding attName}" MinWidth="200" Grid.Column="0" Background="LightBlue" BorderThickness="2"/>
                <TextBox  Text="{Binding sourceValue}" MinWidth="350" Grid.Column="1" BorderThickness="2"/>
                <TextBox  Text="{Binding targetValue}" MinWidth="350" Grid.Column="2" BorderThickness="2"/>
            </Grid>
        </DataTemplate>
    </Window.Resources>
Posted
Comments
kk1001 24-Feb-15 7:49am    
the binding code is

List MyDataSource = new List();
for (int i = 0; i < 5; i++)
{
MyDataSource.Add(new SourceTargetInit("Attribute" + i, "SourceValue" + i, "TargetValue" + i));
}
listSourceTargetCompare.ItemsSource = MyDataSource;

it is showing blank records in list box
kk1001 24-Feb-15 7:49am    
<ListBox Name="listSourceTargetCompare" ItemsSource="{Binding}"
ItemTemplate="{StaticResource ResourceKey=MyDataTemplate}" Margin="89.58,100.031,96.987,143.252" />

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900