![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Problem in dynamic WPF ListView binding | .NET General | |||