Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Dynamic XML Data Binding

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 04-24-2006   #1 (permalink)
Ben
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 SpecsSystem Spec
Old 04-24-2006   #2 (permalink)
Drew Marsh
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 SpecsSystem Spec
Old 04-25-2006   #3 (permalink)
Ben
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51