Overriding styling in Windows Phone 8 - windows-phone-8

I have a dll that our customers integrate that provides UserControls and I want to allow style overrides. In Windows Store I can do:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///MyDLL/Assets/Styles/Default.xaml"/>
<ResourceDictionary Source="ms-appx:///OverrideStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
and it finds the local AppboyStyles.xaml defined in the users app. I can't figure out the right URI for Windows Phone 8 to allow similar functionality.
edit:
Say I have UserControl1 in A.dll, and UserControl1 has a style resource dictionary that looks like:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/A;component/Assets/Styles/Default.xaml"/>
<ResourceDictionary Source="/TestApp;component/Assets/Styles/Override.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
This will actually work in TestApp, but I can't hardcode one calling app because it's a library to be distributed. So I need a way to either substitute for the calling app dll name, or use a URI that evaluates to the current app's resources.

Related

Custom coding standard ruleset not working for Code Sniffer in PhpStorm

I have a project in PhpStorm 2019.2.3 for which I want to use a custom coding standard ruleset with PHP Code Sniffer. The Code Sniffer works as expected, when I choose a provided coding standard, but when I change to my custom ruleset, all sniffs disappear.
I copied the whole /PSR2 folder under /PHP_CodeSniffer-3.4.2/src/Standards/, named it PSR2-Custom and edited the contained ruleset.xml to this:
<?xml version="1.0"?>
<ruleset name="PSR2R">
<rule ref="PSR2">
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
</rule>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
</ruleset>
What I think it does is that it uses the PSR2 coding standard and excludes two of the contained rules, inspired by phpcs: How can I modify PSR2 to check that the brace is on the same line as the method? and https://github.com/squizlabs/PHP_CodeSniffer/issues/703
These are my settings:
A) Settings > Languages & Frameworks > PHP > Quality Tools:
local configuration with path to phpcs.bat (PHP_CodeSniffer-3.4.2, manually downloaded) (as documented)
B) Settings > Editor > Inspections: PHP > Quality tools > PHP Code Sniffer Validation:
-> choosing PSR2 in 'Coding standards' dropdown: sniffs marked
-> choosing PSR2-Custom in 'Coding standards' dropdown: no sniffs marked anymore
I checked similar issues on SO, but non of them helped me with my problem, e.g.
Custom PMD ruleset not working
I can't figure out, where I went wrong. Is my ruleset config buggy? Thanks for helping out.

What's the difference between Properties/DisplayName element and VisualElements#DisplayName attribute in .appxmanifest file

In following appxmanifest, what is the difference between
Package/Properties/DisplayName element
and
Package/Applications/Application/VisualElements#DisplayName
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
<Identity Name=""
Version=""
Publisher="" />
<Properties>
<DisplayName></DisplayName> <!-- this -->
<PublisherDisplayName></PublisherDisplayName>
<Logo></Logo>
</Properties>
<Prerequisites>
<OSMinVersion></OSMinVersion>
<OSMaxVersionTested></OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="" />
</Resources>
<Applications>
<Application Id="" StartPage="">
<!-- and this -->
<VisualElements DisplayName=""
Description=""
Logo="" SmallLogo=""
ForegroundText="" BackgroundColor="">
<SplashScreen Image="" />
</VisualElements>
</Application>
</Applications>
</Package>
https://msdn.microsoft.com/en-us/library/windows/apps/br211475.aspx
Package/Properties/DisplayName
The DisplayName is the name of your app that you reserve in the store, for apps which are uploaded to the store.
This is the actual reserved name in the developer portal (= store). When you package your app for upload to the store, this will be automatically set when going through the wizard in Visual Studio.
The root element Visual Elements is how the Windows Store app is visualized on the user's pc/phone.
Package/Applications/Application/VisualElements
Describes the visual aspects of the Windows Store app: its default tile, logo images, text and background colors, initial screen orientation, splash screen, and lock screen tile appearance.
So the DisplayName property under the Visual Elements element is how the app's name is shown on the user's pc. This can be different from the name in the store (e.g. localized).
A friendly name for the app that can be displayed to users. This string is localizable; see Remarks for details.
There are two explicitly reserved words that may not be used as the DisplayName for apps uploaded to the Windows Store: "NoUIEntryPoints" and "NoUIEntryPoints-DesignMode". These identifiers are reserved for use by development tools and test suites.
Source: https://msdn.microsoft.com/en-us/library/windows/apps/br211471.aspx
I have an app in the Store that may explain this issue.
Package/Properties/Display Name element refers to the app name in the Store which is the same as what's in Dashboard. While if you change the Display Name distribute in Visual Elements, your app will be different from itself in the Store after user installs it from the Store.

Access Asset Catalog images in TVML

I there any way to access images in contained within a local Asset Catalog from within TVML on the AppleTV?
I notice several of the templates in this example from Apple call out to resource:// URLs, which are common use images (more info on the dev forms). Here's an example button that gets rendered with the cloud symbol:
<buttonLockup>
<badge src="resource://button-cloud" class="whiteBadge" />
<title>Title 3</title>
</buttonLockup>
I tried pointing to some of my own resources instead of button-cloud but didn't have any success.
I have been able to change the icon on these buttons by linking to an externally served image like so:
<buttonLockup>
<badge src="http://localhost:5000/static/heartFull.png" class="whiteBadge" width="50" height="50"/>
<title>Title 3</title>
</buttonLockup>
Since these buttons will be re-used throughout my app, I'd rather load them locally than repeatedly calling them over HTTP if possible.
I had some success linking directly to the filesystem
<badge src=\"file:///<url to bundle>/<relative path to resource>/<icon>.png\" width=\"50\" height=\"50\" />
with... url to bundle from NSBundle.mainBundle().bundleURL.absoluteString, relative path according to your setup, eg. resources, images, ... and icon well, your image to show on the badge.
Pulling from Assets.xcassets hasn't worked out so far, but then I am still in training. :-D
I think the icons namespaced with resource are provided by the OS itself and can't be modified. This is only a hunch and I haven't verified it.
https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/ATV_Template_Guide/ResourceValues.html
Thanks #Baa, really helped me out! Just wanted to add that in order to reference the path to the bundle on the JS side, I needed to add the following Swift code to my AppDelegate.swift file within the appController(_ appController: TVApplicationController, evaluateAppJavaScriptIn jsContext: JSContext) function (may need to be manually added, if you don't see it):
jsContext.setObject(Bundle.main.bundleURL.absoluteString, forKeyedSubscript: "BUNDLE_URL" as NSCopying & NSObjectProtocol)
Then on the JS side, I could load static images from the bundle with the following:
const imageFromBundle = `${BUNDLE_URL}myImageName.png`;
Note, as far as I could see, the file:/// prefix was unnecessary and loading bundled images worked fine for me without it.

Set default navigation page to xaml in a library in WP8

My default page is in a library. How do I point this field to it?
Edit the XML code of your WMAppManifest.xml and replace the property NavigationPage of the following line:
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
to:
{assemblyName};component/{pathToResource}
where the assemblyName is the name of the assembly of the page you want to navigate to, and pathToResource is the path (inside that project) to the page you want to navigate to.

WP8: PhoneApplicationPage.Resources - "Resources" is not recognized or is not accessible

I'm developing my first native Windows Phone 8 application, and I'm new to xaml.
I am trying to create a resources section to contain a DataTemplate using the following markup:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="LoopingSelectorTemplate">
<Grid>
<TextBlock Text="{Binding}" FontSize="32" Foreground="Green"></TextBlock>
</Grid>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
However I am getting an error 'The member "Resources" is not recognized or is not accessible.'
Am I missing a reference, or xmlns? Most search results I find seem to imply that the above markup should work out of the box, and don't mention needing anything else.
Edit:
When I try and build the solution I get the following errors:
'The member "Resources" is not recognized or is not accessible.'
"The attachable property 'Resources' was not found in type 'PhoneApplicationPage'"
and "The property 'Resources' does not exist on the type 'Grid' in the XML namespace 'clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone'"
The problem was that although I was adding this to the MainPage.xaml, it wasn't at the root phone:PhoneApplicationPage tag, but instead it was within a Grid tag.