Binding on orientation property

AlfredoSolisAlfredoSolis Member
edited September 2018 in Xamarin.Forms

Hi, I'm trying bind the Orientation Property of a StackLayout to chage between horizontal and vertical from the ViewModel during the execution. I have the property declared:

private StackOrientation _orientacionDescripcion;
public StackOrientation OrientacionDescripcion
{
        get { return _orientacionDescripcion; }
        set { SetValue(ref _orientacionDescripcion, value); }
}

And in the view:

<StackLayout
        Orientation="{Binding OrientacionDescripcion}">
...
</StackLayout>

But, the orientation is always vertical, How can I correct it?

Thank you for helping me!

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    So what's the question or problem?
    Also, you need to use markdown so the site parser doesn't try to render your code and XAML. That's why we can't see most of what you supplied.
    https://redpillxamarin.com/2016/12/13/faq-frequently-asked-questions/

  • @ClintStLaurent said:
    So what's the question or problem?
    Also, you need to use markdown so the site parser doesn't try to render your code and XAML. That's why we can't see most of what you supplied.

    Thanks for the link, I didn't know how to use the markdowns. I already corrected the question.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    set { SetValue(ref _orientacionDescripcion, value); }

    Well... That's different. I've never seen anyone try it with a ref like that before.
    Is there a reason you don't stick with normal C# syntax? That looks very C++
    set { _orientacionDescripcion = value); }

    Beyond that... There is no raising of INotifyPropertyChanged.

    Do you have other properties on the same VIewModel that are working? Simple strings perhaps, just to confirm your BindingContext?

Sign In or Register to comment.