简体   繁体   中英

Binding 2 instances of the same control to different properties

I have a main VM. It instanciate 2 user controls of the same type.

Each control should be bound to a different property of the VM to display its details (and update if it changes).

Would you know how to do so?

I can't figure out how to tell at the instanciation wich property it should hook to... (meaning: I obviously can't pass the property in input at the instanciation)

If I have understood you:

<StackPanel>
    <MyUserControl DataContext="{Binding Property1}" />
    <MyUserControl DataContext="{Binding Property2}" />
</StackPanel>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM