locked
Databinding and event RRS feed

  • Question

  • Hi,

     

    I try to find a way to display elements in a list when I check a checkbox and function of the checkbox, the elements displayed in the list are not the same.

    Moreover elements in the list use databinding.

     

    I try via codebehind, but I don't how to create databinding in it.

     

    If somebody has a solution.

     

     

    Friday, May 4, 2007 3:27 PM

Answers

  • Binding b = new Binding();

    b.Source = ...;

    b.Path = new PropertyPath("...") //optional

    mylistbox.SetBinding(ListBox.ItemsSourceProperty,b);

    Friday, May 4, 2007 3:39 PM
  • Hello, you can do the same as Lee suggested. Just use XPath instead of Path:

                  XmlDataProvider xdp = new XmlDataProvider();

                  xdp.Source = new Uri("data\\BookData.xml", UriKind.Relative);

                  Binding binding = new Binding();

                  binding.Source = xdp;

                  binding.XPath = "Books/*";

                  listBox1.SetBinding(ListBox.ItemsSourceProperty, binding);

    Monday, May 7, 2007 7:38 AM

All replies

  • Binding b = new Binding();

    b.Source = ...;

    b.Path = new PropertyPath("...") //optional

    mylistbox.SetBinding(ListBox.ItemsSourceProperty,b);

    Friday, May 4, 2007 3:39 PM
  • Thanks,

     

    My source is specific elements in an XML File, so I need to get only good nods.

    So how can I create this object Source which represents my XML file and get the best nods ? 

     

    Nobody can help me?

    Friday, May 4, 2007 4:14 PM
  • Hi, nobody answered me.

    I just want to create a Source object which represents an XML file, and get the right nods.

     

    So if somebody has a solution...

     

     

    Saturday, May 5, 2007 8:08 AM
  • Hello, you can do the same as Lee suggested. Just use XPath instead of Path:

                  XmlDataProvider xdp = new XmlDataProvider();

                  xdp.Source = new Uri("data\\BookData.xml", UriKind.Relative);

                  Binding binding = new Binding();

                  binding.Source = xdp;

                  binding.XPath = "Books/*";

                  listBox1.SetBinding(ListBox.ItemsSourceProperty, binding);

    Monday, May 7, 2007 7:38 AM