[UWP]Change Background Image for landscape and portrait orientation RRS feed

  • Question

  • How do I change the background for landscape and portrait orientation in VisualStateManager?

    Thursday, December 17, 2015 1:52 AM

All replies

  • Hello Priscillia,

    I think you will need to use Custom Visual State Triggers. Please see the following blog about how we can do it.

    Generally speaking, we define our own trigger which detect the following:

      var currentview = ApplicationView.GetForCurrentView();
                { }
                else if(currentview.Orientation==ApplicationViewOrientation.Landscape)
                { }

    The above is located at sizechanged event:

     Window.Current.SizeChanged += Current_SizeChanged;

    When the Orientation is Landscape we set the trigger as active. 

    To use the above trigger, we just need to define a trigger name, then do something like the following code:

                <triggers:YourTrigger Orientation="Landsape"/>           

    And set the image in the setter. You can search for OrientationTrigger and Custom Trigger with search engine to understand the whole scenario. 

    Best regards,


    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 18, 2015 3:27 AM