![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Dynamic XML Data Binding I would like to have a dynamic data binding in my application: if I press a button, I bind a text box to an XML Data source, and if I press on another one, I bind it to another XML file... In fact, something like this function on my Button MouseClickHandler: private void loadXML1(object sender, System.Windows.RoutedEventArgs e) { Binding bind = new Binding(); bind.Source = @"c:\xml\xml1.xml"; bind.XPath="/User/Name"; bind.Mode=System.Windows.Data.BindingMode.Default ; this.nameTextBox.SetBinding(TextBlock.TextProperty,bind); } And another one with the @"c:\xml\xml2.xml" path on my other Button. It's not working... what should I change? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Dynamic XML Data Binding ben wrote: > I would like to have a dynamic data binding in my application: if I > press a button, I bind a text box to an XML Data source, and if I > press on another one, I bind it to another XML file... In fact, > something like this function on my Button MouseClickHandler: > > ... code snipped for brevity ... > > And another one with the @"c:\xml\xml2.xml" path on my other Button. > > It's not working... what should I change? You need to define an XmlDataProvider[1], specify that instance as the source of your bindings and then you can change it's Source property in your buttons and anything bound to it should be updated automatically as the new document is loaded. HTH, Drew [1] http://windowssdk.msdn.microsoft.com...taProvider.asp ___________________________________ Drew Marsh Chief Software Architect Mimeo.com, Inc. - http://www.mimeo.com Microsoft C# / WPF MVP Weblog - http://blog.hackedbrain.com/ |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Dynamic XML Data Binding Thanks for the answer, but I really don't know a lot about C# and XAML and have problems implementing it: My XmlDataProvider is: <XmlDataProvider x:Key="XMLdb" d:IsDataSource="True" Source="D:\db_A.xml"/> In the code behind my button, I don't know how to do in order to change the source of this XmlDataProvider. -- Benjamin |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [WPF] data binding and SetValue() | Lloyd Dupont | Avalon | 2 | 06-16-2007 10:08 AM |
| Custom data binding | Matthijs ter Woord | Avalon | 0 | 02-16-2007 10:32 AM |
| data binding | Joerg Engel | Avalon | 1 | 03-22-2006 03:18 AM |
| Data binding with DataGrid | Vijay | Avalon | 1 | 02-21-2006 01:36 PM |
| data binding in viewport3d | Robin Senior | Avalon | 11 | 02-14-2006 05:19 AM |