Click here to Skip to main content
15,946,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I made an application which draws a tree of organization based on values from an xml file.

The xaml file goes like this :

<!-- The Org Chart Data-->
<XmlDataProvider x:Key="organization" Source="model.xml" />

<SolidColorBrush x:Key="ListBorder" Color="#FF7F9DB9"/>

<!-- The Style for Nodes -->
<Style TargetType="{x:Type draw:Node}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Template">

I want to be able to change the source at runtime by selecting a xml file from openfiledialog (like button click) how do i do that?

1 solution

You can do this if you remember that you are referencing this as a resource, so you could do something like this:
XmlDataProvider provider = this.Resources["organization"] as XmlDataProvider;
if (provider != null)
  provider.Source = myXmlDataSource;
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900