Dynamic databind in Expressive Interactive Designer
I'm
not sure this is the right forum but I'll give it a try. I am using
Expressive Interactive Designer January 2006 Community Technology
Preview.
My problem is that I want to generate TextBlocks from
the content of an xml-file. The databind in itself is no problem, I can
get the data from the xml-file to a ListBox. Generating TextBlocks in
the c#-code is no problem either, but I don't get the databind for
those TextBlocks to work.
If I create the TextBlocks manually I can create the databind with this code.
binding.Source = Grid.FindResource("tvDS");
binding.XPath = "/tv/programme[1]/title";
TextBlock1.SetBinding(TextBlock.TextProperty, binding);
This gets the title of the first tv-program and displays it in TextBlock1, just as expected.
When
I loop over the list generated from the xml-file I can create the
TextBlocks that I need, but the databind does not work. This code:
for (i = 0; i < ListBox.Items.Count; i++){
Binding binding = new Binding();
binding.Source = Grid.FindResource("tvDS");
binding.XPath = "/tv/programme[" + i + "]/title)";
TextBlock temp = new TextBlock();
temp.SetBinding(TextBlock.TextProperty, binding);
StackPanel1.Children.Add(temp);
}
Creates the TextBlocks, but for some reason the databind does not work, even though the code is the same. Any ideas? I would be very grateful for some help... Thanks,
Tomas Hansson

