WP8.1 String Resource in ResourceDictionary - xaml

How do I define a string in a ResourceDictionary in my WP8.1 app?
I already added
xmlns:sys="clr-namespace:System;assembly=mscorlib"
to my ResourceDictionary but Visual Studio 2013 says that "sys:String" wasn't found.
How can I fix that?

The problem is probably becouse you are targetting WP8.1 Runtime app. As method you have described will still be working in WP8.1 Silverlight, in Runtime you can declare build-in types in xaml like this:
<x:String x:Key="myKey">Text</x:String>
More about differences and porting Silverlight app to Runtime you will find here at MSDN.

Related

How do I know if an application uses Silverlight?

I am looking at a legacy .NET application and need to know if it is using Silverlight. If it is, I need to migrate the code to WPF, XAML, or HTML5.
Is there a specific set of namespaces and references that tell me that this is a Silverlight application?
Some indicators:
the ProjectTypeGuids element in the .csproj/.vbproj files contains the Silverlight project GUID: {A1591282-1198-4647-A2B1-27E5FF5F6F3B}
the System.* dependencies, when observed in the property grid in Visual Studio, would have version 5.0.5.0 or similar.
You can see a Silverlight project property with bellow link
Silverlight project property

Xamarin Forms in Visual Studio 2017 XAML validation

I am really new to Xamarin.Forms and trying to learn using this nice tutorial.
I have managed to set up everything in Visual Studio 2017 Community Edition and successfully deploy to both emulated and physical devices (Android only).
During various trials, I have noticed that some XAML errors are not highlighted and build is successfully performed, but XAML failed at runtime, crashing the app. E.g. misspell a style name or any an attribute value.
Running in debug mode will just hang the app. Breaking it indicates the following line:
public partial class MainPage : global::Xamarin.Forms.ContentPage { [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
private void InitializeComponent() {
// this is the last line from my code that hands when XAML is invalid
this.LoadFromXaml(typeof(MainPage));
}
}
Resuming the execution shows a hint of what is wrong (no fancy details as provided by the new VS2017 exception interface):
Unhandled Exception:
Xamarin.Forms.Xaml.XamlParseException: occurred
Question: Is there a way to catch invalid XAML errors earlier? Or at least obtain more relevant information? Or is this a known limitation of Xamarin.Forms?
To make things worse, autocomplete for attribute values does not seem to work in VS2017 (it works in VS2015), but this is another issue for another question.
Further details about installed software:
Microsoft Visual Studio Community 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586
Installed Version: Community
Xamarin 4.3.0.795 (aece090)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android SDK 7.1.0.41 (9578cdc)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 10.4.0.123 (35d1ccd)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
To catch XAML errors at compilation time you have to add one line to AssemblyInfo.cs :
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
More information on this can be found here.
Unfortunately Xamarin.Forms XAML intellisense support in VS is not like for WPF or SilverLight, it's very limited currently. One suggestion can be to write your ui in code, this way you will get a feedback faster and if you are very new to Xamarin.Forms XAML you can get familiar with it much easier because of intellisense in code behind.
Another option is to use IDE extensions, in your case as I understand it is VS 2017 for Windows so it will not help you, but for Xamarin Studio for MC you have tools like mfractor, that build to solve the issues you addressed.

VB.NET DLL not possible in a Xamarin.Forms app?

I'm trying to reference a VB.NET DLL in a Xamarin.Forms (Portable) application. During the course of my research, I found the following post that might allow this: Xamarin.Android and VB.Net Libraries
I've tried to use the "Embed" work-around mentioned in the link, but the Xamarin.Forms project would fail to build because it can't load the Microsoft.VisualBasic assembly, version 8.0.0.0.
I've also found the following link as well during my research that should allow at least some VB.NET usage in a Xamarin application: https://developer.xamarin.com/guides/cross-platform/application_fundamentals/pcl/portable_visual_basic_net/xamarin-forms/
At the bottom of the site, there is a "Limitations of VB.NET in Xamarin.Forms" section. With the last item: "Xamarin does not support the Visual Basic.NET language," does that simply mean that you can't use a VB.NET dll in any Xamarin.Forms (portable) project that happens to also reference Xamarin.Forms.Core, Xamarin.Forms.Platform, and Xamarin.Forms.Xaml?
Thanks for any insight!
A DLL doesn't contain it's dependencies. If your DLL relies on Microsoft.VisualBasic, you will need to load the DLL that contains that assembly as well.
So either remove the Microsoft.VisualBasic assembly reference from the VB DLL, or include it as a reference in your Xamarin project (which may or may not be possible, I am not sure.)

XAML Designer not loading WinRT Toolkit for windows phone 8.1

I'm trying to use the WinRT Toolkit for wp 8.1 in my project. I installed the package from nuget and have written this snippet in the main grid.The Emulator works just fine. but The XAML Designer is not loading the control, what do I need to do?
<faysal:CascadingTextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="fafdsda"
FontSize="35"
/>
the namespace in the xaml is like below
xmlns:faysal="using:WinRTXamlToolkit.Controls"
WinRT XAML Toolkit doesn't have good support for design view unfortunately. CascadingTextBlock is one of the controls that simply doesn't show up in the designer.
To install WinRT XAML Toolkit - Data Visualization Controls, run the following command in the Package Manager Console
Install-Package WinRTXamlToolkit.Controls.DataVisualization
then xmlns:faysal="using:WinRTXamlToolkit.Controls"

how to build xaml ui in Cocos2d for windows 8 metro application?

we have been use cocos2d for windows 8 build metro game . so we want use xaml control UI in cocos2d ?
is there have soluction or suggestion?
just try one night i have been fix this problem. you can click fllow link:
DirectX and XAML interop (Windows Store apps using C++ and DirectX) (Windows) http://msdn.microsoft.com/en-us/library/windows/apps/hh825871.aspx
With the release of Windows 8, you can use XAML and Direct X together in your Windows Store app. The combination of XAML and DirectX lets you build flexible user interface frameworks that interop with your DirectX-rendered content, and is particularly useful for graphics-intensive apps. We explain the structure of a XAML app that uses DirectX, and identify the important types to use when building your XAML app to work with DirectX.
soluction as fllow link:
http://www.cnblogs.com/chenkai/archive/2012/11/29/2794983.html
by chenkai
Here's a template project in my github:
https://github.com/chanyuenpang/cocos2dxaml