How I can have a string value like "PropertyBag["ABCD"]" ? I want it to assign to a value of a chart in my WPF App. I am using it like as shown below :
private void Window_Loaded(object sender, RoutedEventArgs e) { ViewModel vm = new ViewModel(); foreach (var str in vm.Data) { string name = "ABCD"; LineSeries lineSeries = new LineSeries(); lineSeries.ItemsSource = new ViewModel().Data; lineSeries.XBindingPath = "Date"; lineSeries.YBindingPath = "PropertyBag[\" + name + \"]"; // here i am getting error saying - Input string was not in a correct format lineSeries.IsSeriesVisible = true; lineSeries.ShowTooltip = true; chart.Series.Add(lineSeries); } this.DataContext = vm; } I want it like lineSeries.YBindingPath = "PropertyBag["ABCD"]" // (should include all 4 double quotes). How it is possible ??
I tried this also, but still same error :
lineSeries.YBindingPath = String.Format(@"PropertBag[""{0}""]", name);
YBindingPathto look like? This isn't really a C# issue - it's a matter of "whatever the library you're using can accept".lineSeries.YBindingPath = $"PropertyBag[\"{name}\"]";, However, this almost certainly the wrong way to bind the WPF control.