Page 1 of 1

[SOLVED] Is the DataBinding feature limited?

Posted: Sun Oct 30, 2016 10:22 am
by cnayan
Hi,

When I try to bind the attached property, then there is compilation error reported. Why is that?

...
<Canvas Canvas.Left="{Binding LeftPanel.X}"
Canvas.Top="{Binding LeftPanel.Y}"

Background="Red" />
...

Error:
Severity Code Description Project File Line Suppression State
Error C#/XAML for HTML5: XamlPreprocessor (pass 2) failed: Property "Canvas" not found in type "Windows.UI.Xaml.Controls.Canvas". Note: the XAML editor sometimes raises errors that are misleading. To see only real non-misleading errors, make sure to close all the XAML editor windows/tabs before compiling. portApp1 C:\Visual Studio 2015\Projects\portApp1\portApp1\Views\MainPage.xaml 12


More details:

Code: Select all

<Page x:Class="portApp1.Views.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:portApp1"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      DataContext="{Binding MainViewModel, Source={StaticResource Locator}}"
      mc:Ignorable="d">
    <Grid Background="#FF00C000">
        <Canvas>
            <Canvas Canvas.Left="{Binding LeftPanel.X}"
                    Canvas.Top="{Binding LeftPanel.Y}"
                    Width="{Binding LeftPanel.Width}"
                    Height="{Binding LeftPanel.Height}"
                    Background="Red" />
        </Canvas>
    </Grid>
</Page>


Code: Select all

    class MainViewModel : ViewModelBase
    {
        LayoutManager _LayoutManager = new LayoutManager();

        public Rect LeftPanel
        {
            get { return _LayoutManager.Left; }
        }
    }


Code: Select all

    class LayoutManager : ViewModels.ViewModelBase
    {
        public Rect Left
        {
            get
            {
                var rectangle = new Rect
                {
                    Width = Screen.Width * 0.25f,
                    Height = Screen.Height
                };

                return rectangle;
            }
        }

        public Rect Screen
        {
            get { return Get<Rect>(); }
            set
            {
                Set(value);
            }
        }
    }

Re: Is the DataBinding feature limited?

Posted: Mon Oct 31, 2016 3:53 am
by JS-Support @Userware
Dear cnayan,

Thank you for reporting this issue. It indeed appears that the binding of Attached Properties does not work properly. We are going to fix it asap.

Thanks.
Regards,
JS-Support

Re: Is the DataBinding feature limited?

Posted: Mon Oct 31, 2016 9:50 am
by cnayan
Thanks, team, for the acknowledgement!

Eagerly waiting for better upcoming version. 8-)

Re: Is the DataBinding feature limited?

Posted: Sat Mar 04, 2017 6:19 pm
by JS-Support @Userware
Hi,

We are pleased to inform you that this issue has been fixed in Beta 10.11 and newer.

You can download it from:
http://forums.cshtml5.com/viewforum.php?f=6

Thanks.
Regards,
JS-Support