3
votes

I'm making C# application for Universal Windows Platform (UWP) and I would like to bind manually to the xaml element from the properties (Create Data Binding... after clicking on rectangle next to ie. Content in Button Properties).

Binding is of course working when I type Content={Binding Text} from keyboard. This has place just in the UWP projects, and it is working for normal WPF applications.

Here is the example: UWP binding example

And code behind:

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        this.DataContext = this;
    }
    public string Text { get; private set; } = "Hello";
}

Has anyone solved this problem because it is slightly annoying?

2
Please note that although both use XAML, UWP and WPF are different frameworks. - Clemens

2 Answers

3
votes

I had a similar problem with Visual Studio. The response from Microsoft was

...due to updates to the XAML designer, some features are currently disabled, including adding Styles through the property marker menu. This functionality will return at a later date. You can find more info at https://blogs.msdn.microsoft.com/visualstudio/2017/09/11/a-significant-update-to-the-xaml-designer/

-3
votes

You would need to give a page name and then you can bind to this property thro element binding.

x:Name="MainPage"> ... Content="{Binding Path=Text, ElementName=MainPage}"