first off the example code, I have a class like so
Public class SomeClass
{
Public int indexNum {get;set;}
Public int value1 {get;set;}
Public int value2 {get;set;}
Public SomeClass(){}
}
I create a list and fill it.
List<SomeClass> AList = new List<SomeClass>();
for(int i =0; i < 5; i++)
{
AList.Add(new SomeClass()
{
indexNum = i,
Value1 = i * 5,
Value2 = i * 2
});
}
MyChart.DataContext = AList;
and the binding in the chart like so
DependentValueBinding="{Binding Value1}" IndependentValueBinding="{Binding indexNum}"
Now on the page there will be a button at the top. When I push the button I would like the DependentValueBinding to switch from Value1 to Value2. Can this all be done in the xaml code or do I have to create all the bindings in the code behind?
You can use XamlWriter.Save method to serialize an object.
And you can use XamlReader.Load method to deserialize the a XAML string.
I couldn't find how to do all this in xaml but in code behind its just as simple as this
((ColumnSeries)MyChart.Series[0]).DependentValueBinding =
new System.Windows.Data.Binding("Value2");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.