I want to implement a dynamic UI where TextBox controls will be created dynamically, and their content bound to a Dictionary on the ViewModel.
I'm trying to implement two-way data binding using ReactiveUI.
The issue I'm facing is that I only seem to be allowed to bind the TextBoxes to an entry in the Dictionary if I use a literal string as the key, but as soon as I try to use a string variable to setup the binding, I get the following error:
Index expressions are only supported with constants.
Here is a very simplified sample of what I'm trying to do. The TextBox is not dynamically instantiated in order to isolate the problem:
string PropNum = "22017";
this.Bind(ViewModel, vm => vm.ExcelData[PropNum], view => view.tbCreate.Text);
In this example, ExcelData is a Dictionary<string, object> defined on the ViewModel.
On the other hand, the following works fine:
this.Bind(ViewModel, vm => vm.ExcelData["22017"], view => view.tbCreate.Text);
I need the lookup key to be a variable. Any ways to achieve this result?
Thanks