I am working on a side project where I have hit a wall after much poking around and could use some help.
Here is the situation: I have a Window that I want to dynamically populate based on a choice in a combobox (easy) so I am building everything programmatically. What I need to build is several boxes that will populate based off of different queries in the same result set. What I was planning on doing was setting the Binding.Source (of the textbox text property) to a Func and that when update source was called then it would auto-magically run that function.
That doesn't happen. Any thoughts on how to bind a text property to a LINQ query that will change over time?
I can provide any more info that is required.
Thanks, Nick
Update Snippets:
private int AllelePopulation(IAllele allele)
{
var list= from b in _population.Populus
from g in b.Genes
where g.Representation == allele.Representation
select b;
return list.ToList().Count;
}
Setting the func as the binding source (parameter name is bindingSource)
var binding = new Binding
{
Source = bindingSource,
Mode = BindingMode.OneWay
};
tb.SetBinding(TextBox.TextProperty, binding);
Something has to do the "magic". In your case it would be a converter which converts a lambda expression to a string.