I'm trying to add a WrapPanel to my app, up to now I found that WrapPanel is only available through SilverLight Toolkit here http://silverlight.codeplex.com/releases
I've downloaded it and installed it, but now what do I do?
I assumed that a reference needed to be added but I can't think of what to add.
Add a reference to Microsoft.Phone.Controls.Toolkit.dll. The WrapPanel control is in the Microsoft.Phone.Controls namespace.
In your page/user control, add the following XML namespace declaration:
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
Then you can add instances of <toolkit:WrapPanel /> in your XAML.
Related
I am designing an app for Windows Phone using the Viual Studio XAML designer. My page is to long to fit into a page so I had to put it inside a ScrollViewer and Grid. This works but my problem is that the designer does not allow me to see (and therefore to some extent interact) with these elements outside the page. Is there any setting or something that I can use to be able to interact with these elements?
Add the following to the XAML element of the page:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DesignHeight="<desired height>"
i.e.:
<phone:PhoneApplicationPage
x:Class="PhoneApp1.MainPage"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DesignHeight="1600"
....more attributes...
>
<!-- other stuff -->
</phone:PhoneApplicationPage>
The xml namespace definition for "d" is probably already present, and the same can be done for the design time width, of course.
Was wondering if someone had a good idea of how to handle this.
In WP7.1, we can utilize the excellent Windows Phone Toolkit to include some useful controls such as LongListSelector and Panorama. These are part of the Microsoft.Phone.Controls.Toolkit assembly.
In WP8, we do not need the toolkit for those two controls because they're part of the official Microsoft.Phone.Controls assembly.
I have multi-targeted my app so that I have two phone projects, WP71 and WP80, where I link files in WP80 to files in WP71.
This works great until I try to use the Panorama or LongListSelector control in a XAML page. In the WP80 project, if I reference the WP80 DLL of the phone toolkit, it does not include the two aforementioned controls because, surprise, they're already present.
The issue is, WP71 needs the namespace declaration at the top of the XAML and the namespace is different for both projects.
WP71:
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
<toolkit:Panorama />
WP80:
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
<phone:Panorama />
I cannot build the projects because each project thinks the namespace is incorrect if I just use one because they need to point to different assemblies.
I don't think I can use compile constants in my XAML, otherwise that would be a fix.
My workaround was originally to just reference the older WP71 DLL in my WP80 project. But other 3rd party libraries bind against the official 8.0 SDK DLL (Caliburn, in my case) so it causes problems.
How can I solve this pickle? The only idea off the top of my head was to resort to code-behind to create the instance of the control :( Is there a better way?
Don't use a link, create a separate view for each.
Another solution might be to create a PanoramaEx control in each of the relative projects and inherit from Panorama. Then the view would reference the PanoramaEx control and you could still use a link to a single view. That's if both UI projects have the same namespace.
Edit: isn't panorama for WP7 in the namespace:
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
I do use my initial solution for ProgressBar and PerformanceProgressBar, I have a ProgressBarEx in each UI project, the WP7 one inherits from ProgressBar and the WP8 one inherits from PerformanceProgressBar and then in the views I reference ProgressBarEx.
Might not be the most elegant solution, but you can try to use a T4 file (.tt file) to generate both targets.
<## template language="C#" hostspecific="true"#>
<## output extension=".xaml"#>
<## assembly name="EnvDTE" #>
<phone:PhoneApplicationPage
x:Class="PhoneAppDemo.Pages.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
<# IServiceProvider serviceProvider = (IServiceProvider)Host;
EnvDTE.DTE dte = (EnvDTE.DTE)serviceProvider.GetService(typeof(EnvDTE.DTE));
var configName = dte.Solution.SolutionBuild.ActiveConfiguration.Name;
if (configName == "WP7") { #>
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
<# }else{ #>
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
<# } #>
>
<# include file="Page.xaml" #>
</phone:PhoneApplicationPage>
In this example, the inner content of the Page is in "Page.xaml". We just encapsulate it in <phone:PhoneApplicationPage> at processor time, based on the target name (usually Debug and Release, but in this example we assumed there was a target WP7).
For other stuff related to a multi-targeted silverlight app, you can always read Maintaining a WP7 and WP8 version of a same Silverlight application.
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.
SelectionMode property is not found in ListPicker.We included reference to Microsoft.Phone.Controls.Toolkit in our project and also included
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
in the xaml page.But we are not able to give SelectionMode=Multiple
Thank you
Make sure you have the latest version, previous versions didn't have a SelectionMode property
We are currently migrating our app from VB6 to Net. As the Net forms will be in the minority we want them to blend in as good as possible with the VB6 forms. I thought that forcibly applying the Classic theme would accomplish this. This should be easy but I can't find how to do it. The examples provided target the Aero theme or Net3 which seems to have differently named referenced assemblies.
There are two ways to accomplish this:
Reference the classic.xaml file that is embedded in the Framework:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Classic;component/themes/classic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
`
Download the extracted classic.xaml file from here
This file holds a reference to the PresentationUI.dll which does not seem to be part of Net 4 framework. There is just one quixotic Control using this reference, so when you remove the reference and the control you are set to go!
More info here