Win10 UWP Development Series: solves compatibility issues caused by Style differences in different Win10 versions. uwpwin10
Recently, when developing a project, I encountered a strange problem: the minimum version of the project dependency is 10586, and the target version is 14393. After the development is completed and released to the store, many users report that the page cannot be loaded normally. After investigation, all the problems were caused by Win10 10586.
This problem also exists in the Custom AppBar control I wrote in my previous blog. 10586 will report an error.
For this reason, we download the 10586 SDK for debugging. The error message is displayed. A style cannot be found and is named ListViewItemBackground. Because it is based on 14393 during development, it is possible that this style is available by default in SDK 14393, but not in SDK 10586.
First, find the following directory:
C: \ Program Files (x86) \ Windows Kits \ 10 \ DesignTime \ CommonConfiguration \ Neutral \ UAP
The following three directories are displayed:
These are three different versions of win10. Open the Generic Directory in sequence, and generic. xaml is the default Style File. To compare the differences between the three versions, VS Code users can install this plug-in:
After installation, reload the three versions of generic. drag in The xaml file. Right-click the first file to be compared and select Mark 1st file. Right-click the second file and choose Mark 2nd file for comparison.
First, find the value ListViewItemBackground and find that 14393 contains this attribute, but 10586 does not. If this value is not found, an error is returned:
We can see that the difference is large.
The problem with the custom AppBar is that the template I copied from the 14393 style is like this:
In 10586, The AppBar template is as follows:
But in 14393, it is actually the same as the value of 10586:
That is to say, some resources are re-named in 14393. The legendary Microsoft rename Department again made a difference.
Make a comparison between 14393 and 15063, and you can find some minor changes:
Therefore, if you want to use these styles, make sure they exist in the default styles of different versions. Otherwise, the resource cannot be found and an error is reported.
So how can we solve this problem? One solution is to copy the part that does not exist in the default 14393 style to the project. However, if you use a custom control, you may still find some inexplicable errors. For example, some control templates use properties that are only supported by 14393. refer to the following articles:
Http://stackoverflow.com/questions/40397909/templatebinding-used-after-must-be-a-markup-extension-error-on-uwp-gridvi
Https://social.msdn.microsoft.com/Forums/windowsapps/en-US/af308462-59b3-4ec6-9640-f0a3c5956004/uwptemplatebinding-used-after-must-be-a-markup-extension-error-on-uwp-gridview? Forum = wpdevelop
For the sake of insurance, you can change the minimum version of the project to 14393. It should be noted that the style of 15063 is still changed, and compatibility should be considered if the template is customized.