0
votes

I am trying to work out data binding in C# in a wpf application and I got struck. I have a program and I need to bind my project settings, which can be changed and are displayed in a UI.

UI:

<ListView Name="lsview">
   <ListView.DataContext >
      <Binding Source="projpro"/>
   </ListView.DataContext>
   <ListView.View>
      <GridView>
         <GridViewColumn>
            <TextBox Width="150" Name="projid" Text="{Binding Path=pp.test}" />                                            
         </GridViewColumn>
         <GridViewColumn>
            <TextBox Width="150">wtf from xaml</TextBox>
         </GridViewColumn>
      </GridView>
   </ListView.View>
</ListView>

Code:

 public MainWindow()
 {
    InitializeComponent();
    displayImage(true);
    projectProperties();
    projpro pp = new projpro();

    lsview.DataContext = pp;
 }

class:

class projpro
{
    string a="check1";

    public string test
    {
        get { return a ; }
        set
        {
            a = "check2";

        }
    }

}

The class projpro needs to be a list of several parameters. I want to know how to display it. I have set path to pp. and I want to display the value of test in the UI. I read some artcles on MSDN but still I am clear how to access the code from xaml. The values are dynamic in the class.

please throw some light.

Thanks a lot in advance.

cheers

1
aaha, got it. not pp.test. its just test. :D thanks for reading. - Naresh

1 Answers

0
votes

Try with the propertyName on the Cell Binding.

<TextBox Width="150" Name="projid" Text="{Binding Path=test}" />