Windows phone的7.1 ListPicker,简单的方法去全模式? [英] Windows phone 7.1 ListPicker, easy way to go full mode?

查看:155
本文介绍了Windows phone的7.1 ListPicker,简单的方法去全模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用带有 ListPickerMode =全 ListPicker 控制器来获得全屏挑窗口。然而,它只是产生一个错误,当我尝试



型'System.Windows.Markup.XamlParseException的第一次机会异常出现在System.Windows.dll中



更多信息:设置属性 Microsoft.P​​hone.Controls.ListPicker.ListPickerMode 抛出异常[行:49职位:57 ]



下面是我的代码:

 <工具箱:ListPicker X:NAME =OutputSelectorListPickerMode =全
保证金=0,542,6,0标题=输出型WIDTH =450VerticalAlignment =顶部/>



我使用列表设置为的ItemSource如果这是任何帮助填充我ListPicker在C#。
的另一件事是,当我尝试在XML写ListPickerMode这行的也把它作为一个选项,但是当我写了整个事情它表明​​全,扩展和正常。



如果我增加5项,它会自动使用FullMode的ListPicker,我试图改变ItemCountThreshold =0,但只是产生更多的错误。



我使用WINDOWNS手机OS 7.1 2011年8月发布。



这可能只是我,是愚蠢的,第一天的Windows Phone编程:)



更新



那么它看起来像ItemCountThreshold&放!; ListPickerMode是删除7.1什么的,ATLEAST在XAML中的一部分,而不是C#的一部分,他们是只读的。



解决我的问题!



 <工具箱:ListPicker X:NAME =OutputSelectorExpansionMode =FullScreenOnly
保证金=0,542,6,0标题= 输出型WIDTH =450VerticalAlignment =顶部/>



ExpansionMode将使Listpicker出现在全屏或扩展。


< DIV CLASS =h2_lin>解决方案

作为Silverlight工具包[1]的问题跟踪陈述,ItemCountThreshold不应设置(而不能使用简单的XAML中设置)。



不过,也有此问题的两种解决方法。如果你不介意使用代码隐藏,通过的SetValue设置属性:

  //例如,在构造函数中,只后的InitializeComponent(); 
ListPicker.SetValue(Microsoft.P​​hone.Controls.ListPicker.ItemCountThresholdProperty,0);

要在XAML中设置的值,可以使用绑定:

 <工具箱:ListPicker ItemCountThreshold ={结合雨果,FallbackValue = 0}>(...)

在这个例子中,我使用了一个假的绑定表达式并设置使用FallbackValue值。当然,在实际工作的结合应正常工作。该XAML的做法是只在WP8 SDK测试,但它应该在7.1工作以及



编辑:刚刚发现了XAML的做法打破了设计师

[1] http://silverlight.codeplex.com/workitem/9742


I'm trying to use the ListPicker controller with ListPickerMode="Full", to get the fullscreen pick window. However it just generate an error when i try

"A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.dll

Additional information: Set property Microsoft.Phone.Controls.ListPicker.ListPickerMode threw an exception. [Line: 49 Position: 57]"

Here's my code:

<toolkit:ListPicker x:Name="OutputSelector" ListPickerMode="Full"   
Margin="0,542,6,0" Header="Output Type" Width="450" VerticalAlignment="Top" />

I populate my ListPicker in C# using a list to set as ItemSource if that is any help. Another thing is that when i try to write "ListPickerMode" in xml it doest give it as an option, but when i have written the whole thing it suggest "Full" "expanded" and "Normal".

If i add 5 items to the ListPicker it automatically uses FullMode, and i have tried changing ItemCountThreshold="0" but that just generate more errors.

I'm using Windowns Phone 7.1 OS 2011 aug release.

It's probably just me that is stupid, first day with Windows Phone programing :)

UPDATE!

Well it looks like ItemCountThreshold & ListPickerMode was remove for 7.1 or something, atleast in XAML part, not the C# part, where they are read only.

Solution for my problem!

<toolkit:ListPicker x:Name="OutputSelector" ExpansionMode="FullScreenOnly"   
Margin="0,542,6,0" Header="Output Type" Width="450" VerticalAlignment="Top" />

The ExpansionMode will make the Listpicker appear in fullscreen or expanded.

解决方案

As stated in the issue tracker of the silverlight toolkit [1], ItemCountThreshold should not be set (and cannot be set using simple xaml).

However, there are two workarounds for this issue. If you you don't mind to use codebehind, set the property via SetValue:

//e.g., in the constructor, just after InitializeComponent();
ListPicker.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 0);

To set the value in xaml, you can use a binding:

<toolkit:ListPicker ItemCountThreshold="{Binding Hugo,FallbackValue=0}">(...)

In this example, I use a bogus binding expression and set the value using FallbackValue. Of course, an actual working binding should work as well. The xaml approach was only tested on the WP8 SDK, however it should work on 7.1 as well.

Edit: Just found out that the xaml approach breaks the designer.

[1] http://silverlight.codeplex.com/workitem/9742

这篇关于Windows phone的7.1 ListPicker,简单的方法去全模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆