Skip to content

[MVUX] Adding model to Templated Control brakes custom property binding #2270

Closed Answered by dr1rrb
kucint asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @kucint, I've made a sample with both a UserControl and a Control that should give you some insight on how to fix your issue:
UnoAppTemplateBindingWorking.zip

The main point is really to note that a "binding" is relative to a "source". When not specified, the default/implicit source of that binding is the inherited DataContext, and all bindings on an element are relative to the DataContextof that given element.

This means that is you have:

<local:MyControl
    DataContext="{Binding PropertyA}"
    MyProperty="{Binding PropertyB}" />

the binding on MyProperty is relative to the DataContext of MYControl, so it's equivalent to:

<local:MyControl
    MyProperty="{Binding PropertyA.PropertyB}"

Replies: 4 comments 12 replies

Comment options

You must be logged in to vote
3 replies
@francoistanguay
Comment options

@dansiegel
Comment options

@kucint
Comment options

Comment options

You must be logged in to vote
7 replies
@kucint
Comment options

@kucint
Comment options

@kucint
Comment options

@dr1rrb
Comment options

Answer selected by kucint
@kucint
Comment options

@francoistanguay
Comment options

This comment has been hidden.

Comment options

You must be logged in to vote
2 replies
@kucint
Comment options

@francoistanguay
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment