Hi I want to access the CultureTypes in Windows Phone. In Silverlight/WPF i can use like this,
CultureInfo[] specificCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
But In Windows Phone it showing an error as "UnKnownEntity" in CultureTypes
Also I want to get the Id of the CurrentCulture. In Silverlight/WPF, i can use like
Thread.CurrentThread.CurrentCulture.LCID
But in Windows Phone it showing an error as "NotFound" in LCID
Could you please anyone can help me?
In Silverlight/WPF i can use like this
You can in WPF, but not in Silverlight. Look at the Silverlight version of the documentation for CultureInfo - there's no GetCultures method. I don't see any way of getting all cultures - just the current culture, current UI culture, and invariant culture. (You can create your own instances by calling the constructor, of course.)
EDIT: You've run into exactly the same problem when trying to get the LCID. You can't just assume everthing from the desktop framework will be available in Silverlight. You need to look at the Silverlight-specific documentation to see what's available (and then check that it's available on Windows Phone 7, too).
You could use T4 generator to generate missing information. I have done this for similiar problem and works great.
Related
An exception is thrown when setting "ItemContainerStyle" to "StaticResource TreeViewItemStyle" which is defined in generic.xaml. The message indicates the style is using "Windows.UI.Xaml.Controls.TreeViewItem" rather than "Microsoft.UI.Xaml.Controls.TreeViewItem".
I removed ItemContainerStyle assignment to confirm that it is the line causing the exception.
<ControlTemplate TargetType="muxcontrols:TreeView">
<muxcontrols:TreeViewList x:Name="ListControl"
ItemTemplate="{StaticResource TreeViewItemDataTemplate}"
ItemContainerStyle="{StaticResource TreeViewItemStyle}">
The problem seems obvious, but a proper solution evades me. To leverage the style, do I start prepending "muxcontrols:" in the generic.xaml file? This seems like a bad idea. Do I need to recreate the style and behaviors separately?
I tried (min build 17763 and target build 17134) to eliminate version problems, but it seems I need 17763 for both. Even though, I am not setting ItemsSource. I'm trying the technique used in the docs: "learn.microsoft.com/en-us/windows/uwp/design/…" for the Music Library TreeView sample. My real project's min version is 16299.
So, the issue was clear. The TreeView control is introduced from build 17134. If you're using the platform APIs, you need to make sure that your project's target version is 17134 or higher. Since you said you want to set ItemsSource. ItemsSource and its related APIs require Windows 10, version 1809 (SDK 17763) or later, so you need to make your project's target version is 17763.
Then, you could directly use the TreeView control like the following:
<TreeView></TreeView>
If you're using Windows UI Library APIs, you need to follow the Getting started with the Windows UI Library
document to download and install the Windows UI Library. Please note:
Important: To use WinUI 2.1, your project’s Min version must be 14393 or higher and the Target version must be 17763 or higher.
Then, if you want to use the TreeView control in WinUI library, in your XAML page, add a reference at the top of your page
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
On the XAML page, you could directly input the following:
<controls:TreeView></controls:TreeView>
I'm developing an Universal App for Win8.1, i've added the Winrt Xaml Toolkit dll but when i use Calendar control the strings of months appear only in English.
Is there any way to change them? I'm going crazy :D
PS: I've downloaded the source code of dll but there is no track of these strings
If you look at the DateTimeHelper class, you can see the method GetCurrentDateFormat which uses the en-US format. This method is used in many places for the Calendar and CalendarItem controls from the toolkit.
You can try to import the project from the site instead of using the NuGet package and then change this method to use your device locale. You can maybe change it to something like this:
public static DateTimeFormatInfo GetCurrentDateFormat()
{
return CultureInfo.CurrentCulture.DateTimeFormat;
}
I haven't tested this code so this is just a hint where you should look for your solution.
I've problem with using BingMapsDirectionsTask on device with Windows Phone 7.8 and set polish language (pl-PL). In my app I'm trying to call:
var bingMapsDirectionsTask = new BingMapsDirectionsTask();
var destination = new LabeledMapLocation(dest.Name, dest.LocationItem);
bingMapsDirectionsTask.End = destination;
bingMapsDirectionsTask.Show();
When I change device location to other culture, for example en-US the same code works correctly, so I can assume that my code is ok.
I've found some info in Internet about similar problems with other non en cultures. The main workaround based on temporary changing application culture info to en-US:
http://www.apeoholic.se/post/How-to-use-BingMapsDirectionsTask.aspx
http://grenangen.se/node/71
Unfortunately this approach doesn't work with set pl-PL main culture on device. Do you have any suggestions how can I resolve this problem and run Bing maps to show direction to my point?
I can confirm the same behavior with el-GR (Greek) device language. Your code is obviously OK. This is a bug of BingMapsDirectionsTask. Unfortunately it is present even if destination is given in GeoLocation form. Currently there seems to be no way of bypassing this bug.
In the Silverlight 5 beta I could debug databinding directly in XAML. Where is this feature in Visual Studio 2012 (RC)? Can I do this with WPF, WinRT and/or Silverlight? If so how? When I set a breakpoint on a binding expression application, I get the message that the breakpoint will not be hit because no source code is associated with this line.
Update:
It works in Visual Studio 2012 (RC) for Silverlight 5 applications but not for WPF applications. Please don't tell me, that this feature does not exist for WPF!
Sorry to tell you but this feature DOES NOT exist in WPF XAML nor does it exist in WinRT XAML. I can't find an official source for WPF, but here is a pretty official one for WinRT (http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/fae53937-cb47-45da-b740-49f75f8d36e9/) he insinuates pretty strongly that this was an effort spearheaded purely by the Silverlight team and can possibly be expected in future versions of WPF and WinRT.
So far the best debugging techniques I've seen are as follows:
1) WinRT & WPF: Output Window
Using the output window with the proper options enabled, make sure Tools->Options->Debugging->Output Window->Data Binding = "Warning" or something else useful...
2) WinRT & WPF: Use a converter
Using a converter and just setting a break point inside the converter. Or you can build/use something similar to how WinRT XAML Toolkit does: http://winrtxamltoolkit.codeplex.com/.../WinRTXamlToolkit.Debugging/Converters/BindingDebugConverter.cs
3) WinRT: Use DebugSettings.BindingFailed
App.Current.DebugSettings.IsBindingTracingEnabled = true;
App.Current.DebugSettings.BindingFailed += (s, e) =>
{
// debug the failed binding here
};
see: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.debugsettings.bindingfailed for more information
4) WPF: Use PresentationTraceSources.TraceLevel Attached Property
Gives you a verbose output of the binding, see: http://msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.tracelevel.aspx for more information.
I realize this is an older question, but I couldn't find a good source of information for everything XAML, found this answer off a search engine and noticed it was still lacking an answer. It doesn't help that there are technically 3 versions of XAML going by the same moniker. So here's the dump of everything I found while investigating debugging bindings. Enjoy, hope it helps someone... -ck
I'm having a little trouble getting localized resources files to work on Windows Phone 7. Here's what I'm doing:
Create a resource file, say "Strings.resx" (Build Action: Compile)
Create a key, say "TestKey" with a default value of empty string
Add a English resource file in the same folder with a value of "some English string": Strings.en-us.resx (Build Action: Embedded Resource)
Add a Japanese resource file in the same folder with a value of "some Japanese string": Strings.ja-jp.resx (Build Action: Embedded Resource)
In my PC Silverlight, WPF Apps that works fine when I change the Thread.CurrentThread.CurrentCulture. But in the phone I always seem to be getting the value that's in the Strings.resx file - an empty string.
I have tried using the designer generated code and wiring up the resource manager by hand and it does not seem to matter. Here's my code:
Type t = typeof(Strings);
_resourceManager = new ResourceManager(
t.Namespace + "." + t.Name,
t.Assembly);
_resourceManager.GetString("TestKey");
Tell me localized resources are supported on the phone... ;> What am I doing wrong? Thanks!
Update: Thanks Olivier for forwarding the link. I saw that as well but missed an important step. I didn't add the "SupportedCultures" node to my csproj. Made all the difference - hoping someone else doesn't loose two hours trying to figure this out like I did.
<SupportedCultures>de-DE;es-ES;</SupportedCultures>
Of course, localized resources are supported on the phone:
How to: Build a Localized Application for Windows Phone
I wrote a blog post that provides links to a bunch of Globalization / Localization guides for WP7. There is a Windows Phone 7 in 7 Training video that helped me understand the basics. After that it was simply a matter of learning how to do databinding:
The MSDN article shows you how to
setup the files and create the
LocalizedStrings class, but they then
assume that you know how to use that
class for data binding. Visual Studio
2010 and Silverlight handle data
binding differently than Winforms, and
it gets even more confusing since XAML
also has it’s own definition of
Resources that are different then the
.NET resources we just created.
Silverlight also uses the term
Resource to refer to files that use
the the Build Action of "Content”, as
these files get wrapped up into the
.XAP file similar to how files with
Build Action of "Resource” get
embedded into the .Dll assembly (ex:
loading an image from content or
resource files). I found that instead
of using the Text="{Binding
Path=resourceFile.resourceName,
Source={StaticResource
Localizedresources }}" XAML syntax it
was easier to use the following steps:
Open your primary XAML page (usually MainPage.xaml) in the Visual
Studio designer
Open the properties for the PhoneApplicationPage and set the
DataContext to be
Application.Resources –>
LocalizedStrings. NOTE: if you already
are using a DataContext object, then
you should integrate the
LocalizedStrings class into that
object so that it has localization
support.
Once the Page’s DataContext has been set you can change the data
binding for any control on the page by
simply selecting the property (ex:
text, checked, etc), selecting “Apply
Data Binding…”, and setting the Path
to Localizedresources.BtnText or
whatever the name of the desired
resource value is.