Typical fixes after updating Windows Store apps from version 8 to 8.1


    Translating my applications to platform 8.1, I found that this is a fairly simple task that does not require much effort.
    After the translation, typical warnings often arise as a result of platform mismatch. Of course, it is advisable to correct these warnings.
    Consider the most popular fixes?

    When updating, be sure to make a copy of the project directory. Firstly, you will always have a backup, and secondly, you can have versions for Windows 8 and Windows 8.1 in the Store at the same time.

    1. The warning “Windows.ApplicationModel.DataTransfer.DataPackage.SetUri (System.Uri)” is deprecated: “SetUri may be altered or unavailable for releases after Windows 8.1. Instead, use SetWebLink or SetApplicationLink. ”

    The simplest and most easily corrected warning. In version 8.1, setUri was introduced to various SetWebLink and SetApplicationLink methods. If you have a link to a website, then simply replace setUri with SetWebLink

    2. The warning “Windows.UI.Notifications.TileTemplateType.TileWideText04” is deprecated: “TileWideText04 may be altered or unavailable for releases after Windows 8.1. Instead, use TileWide310x150Text04. ”

    Again, just replace TileWideText04 with TileWide310x150Text04 or with a tile template of any other size.

    3. The warning “Windows.UI.Xaml.Controls.ScrollViewer.ScrollToVerticalOffset (double)” is deprecated: “ScrollToVerticalOffset may be altered or unavailable for releases after Windows 8.1. Instead, use ChangeView. ”

    Means that ScrollToVerticalOffset is now an obsolete method. Replace code like the following
    scrollV.ScrollToHorizontalOffset(100); // здесь scrollV это имя элемента ScrollViewer
    scrollV.ScrollToVerticalOffset(0);
    

    on the
    scrollV.ChangeView(100, 0, 1);
    

    4. The warning “Windows.UI.ViewManagement.ApplicationView.Value” is deprecated: “Value may be altered or unavailable for releases after Windows 8.1. Instead, query for window layout sizes directly. ”

    This is the most popular, most frequently occurring warning.
    ApplicationView object is deprecated. In Windows 8.1, 50/50 mode is also added to snap mode. This provides more options for handling application states, but it also forces us to bind to the width of the screen, rather than to the name of a particular state.

    In C # we do it like this:
    Register the Window.Current.SizeChanged + = Window_SizeChanged event;
    And then in the code of the event handler, depending on the screen size of the device, we start the necessary processing:
    private void Window_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
     {
         if (e.Size.Width <= 1000){
    // здесь обрабатываем экран такого размера
     }
         else if (e.Size.Width <= 500){
    // и здесь обрабатываем экран такого размера
     }
         else{}
    // получаем значение текущего расположения ориентации экрана
    ApplicationViewOrientation winOrientation = ApplicationView.GetForCurrentView().Orientation;
        if (winOrientation == ApplicationViewOrientation.Landscape) {
           // альбомная ориентация
        }
        else if (winOrientation == ApplicationViewOrientation.Portrait) {
           // портретная ориентация
        }
     }

    As you can see in the example, the Layout of the screen can still be determined not by aspect ratio, but by name. It is possible that in the near future the orientation of the device can be determined only by the ratio of width to height. If the width is greater, then it is landscape, and if less, then portrait. We’ll do it in a similar JavaScript example (the example from the official guideline already refused to work for me):
    // регистрируем событие resize
        window.addEventListener("resize", function (e) {
        var windowWidth = document.documentElement.offsetWidth;    // получаем ширину окна
        var windowHeight = document.documentElement.offsetHeight;  // получаем высоту окна
            if (windowWidth <= 500) {
                // обрабатываем как нам нужно это состояние
            }else{}
    // определяем, что устройство находится в портретной ориентации, если ширина меньше высоты
       if (windowWidth>windowHeight) {
                // альбомная ориентация
            } else {
                // портретная ориентация
            }
        });
    

    A nice plus in HTML5 applications was and is the ability to set styles for various positions and screen sizes. In 8.1, these media styles were slightly changed from styles indicating the state of the application to styles indicating the width in pixels.
    That is, styles such as:
    @media (-ms-view-state: snapped)
    
    or
    @media (-ms-view-state: filled)
    

    were replaced by classic:
    @media (min-width: 500px) and (max-width: 1023px)
    
    or
    @media (min-width: 1024px)
    

    There are also changes in orientation styles. Now they look like this:
    @media (orientation: landscape) {
        /* CSS стили для альбомной ориентации */
    }
    @media (orientation: portrait) {
        /* CSS стили для портретной ориентации */
    }
    

    For those who found it all too simple, I’ll give you one more rare error that occurs when updating an application created in the developer preview version (it does not threaten most developers).
    After updating, the project refused to open, giving the following error:
    D: \ TesT \ TesT.csproj: error: imported project "C: \ Program Files \ MSBuild \ Microsoft \ WindowsXaml \ v11.0 \ Microsoft.Windows.UI.Xaml.CSharp. targets "not found. Check the path in the Import declaration and the presence of the file on disk. D: \ TesT \ TesT.csproj

    Open the project file and find a similar line in it:

    Replace v $ (VisualStudioVersion) with the version of our studio used. In my case, this is the version of Visual Studio 2013, which means I am replacing it with v12.0

    Summary:
    Updating the application is not only possible, but also easy. Go for it!
    If you manage to do this this year, then you will have the opportunity to participate in the competition and at the same time promote your application.
    Another pretty nice bun from updating the application will be many performance improvements in 8.1 There
    are a lot of changes. He cited only the most popular errors that he himself encountered. I readily read about other errors / warnings in the comments.

    Official Guides and Changelog:
    Changes to the Windows 8.1 API (HTML)
    Changes to the Windows 8.1 API (XAML)

    Also popular now: