c# - Pass Binding Name As Parameter -
c# - Pass Binding Name As Parameter -
in wpf, possible pass name/path of binding parameter? example, have this:
<textbox width="300" text="{binding path=age, updatesourcetrigger=propertychanged, validatesonnotifydataerrors=true, notifyonvalidationerror=true, converter={x:static local:ageconverter.instance}, converterparameter={binding ???}}" /> is there can set instead of ??? parameter value "age"?
as @alessandro mentionned, converterparameter not dependencyproperty does't back upwards info binding.
but since converterparameter regular property of binding class, can set value programmatically. can in code:
var mytextbox = new textbox(); binding mybinding = new binding("age"); mybinding.converterparameter = "set want"; mytextbox.setbinding(textblock.textproperty, mybinding); for example, alter value of converterparameter @ later time in event handler react user input. next time binding updated, phone call converter new converterparameter.
private void button_click(object sender, routedeventargs e) { mybinding.converterparameter = "a different converter parameter"; } c# wpf xaml
Comments
Post a Comment