Microsoft.Phone.Controls.Toolkit ListPicker throws XamlParseException - windows-phone-7

After being advised that the native ComboBox was not the way to go I was told to look at the Silverlight Toolkit ListPicker. So I did and have got a problem.
I opened a new project and pulled a new ListPicker onto the MainPage. The ListPicker looks like:
<toolkit:ListPicker x:Name="Result">
<toolkit:ListPickerItem Content="Win" />
<toolkit:ListPickerItem Content="Place" />
<toolkit:ListPickerItem Content="Lose" />
</toolkit:ListPicker>
When trying to run this I get an XamlParseException with InnerException of InvalidProgramException. All I did was drag the control on, and add some ListPickerItem. Removing the items still results in the error, removing the ListPicker control completely allows the page to be shown with no error.
I'm sure I've missed something, but any documentation I have read seems to point towards this markup being fine, including http://windowsphonegeek.com/articles/listpicker-for-wp7-in-depth
I can provide any other info required.

ListPickerItem is a class used internally by the ListPicker and should not be used directly.
If you just want to add a list of items, you can use strings to do it, like this:
Add a new namespace on top of the Page to access the String class:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Then, just change the ListPicker code to this:
<toolkit:ListPicker>
<sys:String>Win</sys:String>
<sys:String>Place</sys:String>
<sys:String>Lose</sys:String>
</toolkit:ListPicker>

The problem was that the wrong dlls had been registered, i.e. 7 and not 7.1. I had to uninstall and reinstall to get it to update correctly and it worked.

Related

Xamarin XAML designer dose not update any of the transfrom data

The XAML designer is not updating any of the transform values like rotation, translation, etc. It works fine otherwise, it also worker before, it just stopped working suddenly and I don't know what I did.
<Ellipse />
<Rectangle WidthRequest="5" AnchorX="0.5" AnchorY="0.8" TranslationY="-40" Fill="Black" />
<Rectangle AnchorX="0.5" AnchorY="0.8" TranslationY="-40" />
In the above code I used the Translation its not reflecting only in the designer, but if I run the app its updated.
That's what its look like in the designer.
That's what its looks in the output when I run the application, its not reflecting in the XAML designer. So I have to run application every time I need see the result of any update when I use any kind of transform effect.
Try to restart your VS. If the XAML designer does not work everytime with this project or the new project, you could try to repair the VS.

Localization not working (in my app) with windows phone toolkit's date picker

I need the picker page from the toolkit's datepicker control to be in spanish. I tried a few approaches found here on SO, but they didn't work for me.
One thing a noticed is that when i run the sample app from the toolkit, the picker page is localized, but when i run my app which uses the same dll, it does not.
So the question is, what is doing the sample app, that mine doesn't in order for the picker page to be localized?
My DatePicker declaration:
<toolkit:DatePicker Width="280" Background="#96CA04" Foreground="White" Value=" {Binding LeagueBegDate,Mode=TwoWay}" />
Sample App DAtePicker declaration:
<toolkit:DatePicker ValueChanged="DatePicker_ValueChanged"/>
What i had to do was, to open the .csproj file of my project and add es-ES; entry under the <SupportedCultures> node.
I did try adding just es;, but it didn't work. It had to be es-ES; as in the toolkit project, under the LocalizedResources folder the resx files is called: ControlResources.es-ES.resx.
So the entry ended up looking like this:
<SupportedCultures>
es; es-ES;
</SupportedCultures>
To clarify, i did not have to add a localized resources file in my project, just added the supported cultures and the toolkit's localization kicked in.

I cant get LongLister Toolkit in my system

Hi I got following error
I added reference from phone.controls.assembly.toolkit but it doesnt work
The tag 'LongListSelector' does not exist in XML namespac 'clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit'.
When you add a new reference to your library, or in this case, your toolkit, you must also add a reference in your XAML code.
For eg:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
So in your XAML page, go right to the top, you will see a couple lines like the one above.
type xmlns:toolkit="LINK TO YOUR TOOLKIT"
When you type xmlns, intellisense will automatically prompt you to a list of available references. You can scroll down to find it.
Make sure you add a unique name like 'toolkit' or 'tool' after xmlns. So to access the LongListSelector, all you have to do is type
<toolkit:LongListSelector />

Wp7 background image not showing up when i debug

I'm new to WP7 programming but have XP with other platforms, I am just running through all the basics so I can get to know the language but I have hit a roadblock I've entered a source for my background image:
<Grid x:Name="LayoutRoot">
<Grid.Background>
<ImageBrush ImageSource="C:/users/hypernova/pictures/Background1.jpg">
</ImageBrush>
</Grid.Background>
</Grid>
And the image shows up as a background in the design tab that is next to the XAML but when I debug and the emulator starts its just a black screen no background image, what have I missed? I have tried other ways of setting a background like:
<Grid x:Name="LayoutRoot">
<Canvas>
<Canvas.Background>
<ImageBrush ImageSource="C:/users/hypernova/pictures/Background1.jpg">
</ImageBrush>
</Canvas.Background>
</Canvas>
</Grid>
but the same thing happens I've tried a few other ways also but again nothing, I'm sure I've missed something I should have caught.
The path
C:/users/hypernova/pictures/Background1.jpg
exists on your dev machine, not on any Windows Phone 7+ device.
Remember, users will be downloading your app from the store, then running it on their phones. How would they possibly access your hard drive and get that image?
Unfortunately, since the design surface allows you to do this, it can of course be confusing to a new developer.
What you should do is add your image to your project as a Resource, then reference the resource via a pack URI (don't click on that link unless you want to scare yourself silly).
To add it as a resource, simply add the image to the root of your WP7 project, right click on it, select Properties, and then change the build action to Resource (not Embedded Resource, mind you).
Next, you have to construct a pack URI for this resource. This is ... not easy. You can use the tools in Visual Studio to do this, by editing the properties of your ImageBrush in the designer. This is the simplest, and recommended, route. All you have to do is edit the ImageSource of your ImageBrush in the Properties tool window, and select the image from the list of available images in the solution.
The other way is to manually construct the pack URI. For example, you could take the following
/[project assembly name];component/Background1.jpg
replace [project assembly name] with the name of your assembly (no extensions), and use it as your ImageSource value. You can find the correct project assembly name by looking at the Assembly Name under the Application section of the project properties.
<ImageBrush ImageSource="/MyWp7Application;component/Background1.jpg"/>
Note, depending on how your project folder structure is constructed, this URI may be different. Constructing the correct URI outside of the tools provided is a task deserving of another question.

Binding to x:Name in XAML breaks my app in Mango

This line works in Windows Phone 7.0 but not in 7.1 (NullReferenceException thrown). Note that I checked that Name is never null or empty.
<CheckBox x:Name="{Binding Name}" Content="{Binding Label}" />
Removing x:Name, all things being equal, prevent the app to crash. Why is that ?
You can't bind x:Name , it's the equivalent of declaring a variable in C#. And it doesn't make sense to do either, as it's not a visual property.
Surely you meant to bind the Header property of the CheckBox?
My openion is Name property didn't take at runtime.
When you upgraded from 7.0 to 7.1 the xmlns:x in your header might be wrong. create a brand new page and make sure that that line is the same.

Resources