i have these double values:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
double num1 = 50.0;
double num2 = 90.0;
double num3 = 120.0;
double num4 = 20.0;
double num5 = 80.0;
}
}
how do i bind them to xaml?
<vc:Chart.Series>
<vc:DataSeries RenderAs="Column" AxisYType="Primary" >
<vc:DataSeries.DataPoints>
<vc:DataPoint AxisXLabel="Wall-Mart" YValue="{Binding Source={StaticResource num1}}" />
....
help please
You can’t. They are variables with scope local to window constructor. You might want to turn them into public static fields like this:
… and then reference them in XAML using {x:Static} markup extension like so:
Alternatively, you may want to turn them into properties if they are meant to be changed like:
Ultimately, you may make them a DependencyProperty if changes are to be automatically detected by XAML UI.