I have come back to this question to flag it as a duplicate as its essence was how to set up a basic data binding, which has been answered many times, here is one of the good answers: (I would delete this question if I could)
-
Sometimes it's helpful to read a book or an article about the essentials of a technology before trying to use it. For WPF data binding I'd suggest to read the Data Binding Overview article on MSDN for a basic understanding.Clemens– Clemens2016-09-19 21:21:34 +00:00Commented Sep 19, 2016 at 21:21
1 Answer
Your problem is that you are trying to bind to a Method instead of a property. Try something like this:
public static bool fruitLimits
{
get
{ /*your method code here*/ }
}
EDIT: There is no way to pass arguments into the Property, so if you don't have access to the values of the text box you may have to write a converter that gets these values passed. Here the basics: link You can pass one object as the value and the other as the parameter. The converter then processes the information and returns a bool. Here an example of what the Binding of this Converter should look like:
Here an example, your binding should look something like this:
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource converterKey}">
<Binding ElementName="boxVariable" />
<Binding ElementName="textboxDec" Path="Text" />
</MultiBinding>
</DataTrigger.Binding>
Replace the "ElementName=boxVariable" and "ElementName=textboxDec" with the names of the controls you want to pass. You may have to add "Path=Text" on the textbox binding.
Then in the IMultiValueConverter do something like this:
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value[0].GetType().Equals(typeof(ComboBox)) && value[1].GetType().Equals(typeof(String)))
{
ComboBox boxVariable = value[0] as ComboBox;
string textboxDec = value[1] as String;
/* your method code here, returns Boolean */
}
}