c# - Use Binding in Resource without styles -
this question has answer here:
- binding resource 2 answers
i have multibinding
defined follows:
<multibinding stringformat="{0}_{1}"> <binding path="..." /> <binding path="..." /> </multibinding>
i need use in multiple places, , want define in resources, as:
<multibinding x:name="mydefaultbinding" stringformat="..."> <!-- etc --> </multibinding>
however, cannot work out how use it. tried staticresource
like:
<textblock text="{staticresource mydefaultbinding}" style="{staticresource someotherstyle}" />
this gave me compile error: "invalid resource type: expected type 'string', actual type 'multibinding'.".
when tried access using binding
like:
<textblock text="{binding source={staticresource mydefaultbinding}}" style="{staticresource someotherstyle}" />
it compiles, @ runtime text in textblock
set "system.windows.data.multibinding" instead of expected value.
i've seen suggestions propose wrapping multibinding
in style
, have other shared styles defined on controls need use binding.
can evalute binding defined in resources without wrapping in style?
you can't reuse binding resource as-is create markup extension applies resource suggested here:
Comments
Post a Comment