Anss
Anss

Reputation: 674

Cannot bind object to view using Caliburn - UWP

I am trying to bind an object using Caliburn, and use some of its properties (ReferredBy, in this case) for taking input. I can't seem to do it, here is my code:

<StackPanel Orientation="Horizontal" DataContext="{Binding Sponsor}" Margin="20">
<TextBlock Text="Referred By" />
<TextBox Name="ReferredBy" Width="100" Height="20"/>
</StackPanel>

Sponsor is an object in the corresponding ViewModel,

 public Sponsor Sponsor { get; private set; }

Aso, Sponsor is initialized on page load. I can access any other variable I declare in viewmodel by Caliburn's naming convention but not this model. Any help will be appreciated.

Upvotes: 0

Views: 112

Answers (1)

Doom5
Doom5

Reputation: 858

You can bind nested properties with the following convention:

<TextBox Name="Sponsor_ReferredBy" Width="100" Height="20"/>

This way you won't need to bind Sponsor to the enclosing StackPanel.

Upvotes: 1

Related Questions