Reputation: 1764
I have a very long and repeating binding expression in xaml. Can I first define it in resource section and then refer to it using DynamicResource or StaticResource? Something like:
<SomeControl Visibility="{DynamicResource BindingToParentDataContext}">
The binding expression looks like:
{Binding Path=DataContext.SomeProperty, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:SomeParentUserControl}}, Mode=OneWay, Converter={StaticResource booleanToVisibilityConverter}}
Upvotes: 1
Views: 604
Reputation: 11051
What might work is to write a custom markup extension. This should be a good reference.
But besides that, you can't "predefine" markups like that. Depending on your scenario, you might can put some of these into a datatemplate, which you can reuse.
Upvotes: 2
Reputation: 185410
You cannot declare a Binding
in a resource dictionary, i doubt that this can be made to work using resources.
Upvotes: 0