Set some default value for the DataProvider so that it is already configured and bound to your user interface.
Take a value from the user at runtime, and then pass it to the data provider by calling and updating FindResource ...
var myValue = GetFromUser();
((ObjectDataProvider)this.FindResource("ADUsers")).MethodParameters.Clear();
((ObjectDataProvider)this.FindResource("ADUsers")).MethodParameters.Add(myValue);
((ObjectDataProvider )this.FindResource("ADUsers")).Refresh();
Or another tricky way to associate OneWayToSource with MethodParameters ...
<TextBox x:Name="UserInput">
<TextBox.Text>
<Binding Source="{StaticResource ADUsers}"
Path="MethodParameters[0]"
BindsDirectlyToSource="True"
Mode="OneWayToSource">
</Binding>
</TextBox.Text>
</TextBox>
TextBox Text () , , , .
, , .
public class IntToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int intValue = 0;
string strText = value?.ToString();
if (!string.IsNullOrEmpty(strText))
{
intValue = int.Parse(strText);
}
return intValue;
}
}