Ols*_*ssN 19 c# windows-phone-7.1
我正在尝试使用ListPicker
控制器ListPickerMode="Full"
,以获得全屏选择窗口.但是,当我尝试时它只会产生错误
"System.Windows.dll中出现'System.Windows.Markup.XamlParseException'类型的第一次机会异常
附加信息:Set property Microsoft.Phone.Controls.ListPicker.ListPickerMode
引发了异常.[线:49位置:57]"
这是我的代码:
<toolkit:ListPicker x:Name="OutputSelector" ListPickerMode="Full"
Margin="0,542,6,0" Header="Output Type" Width="450" VerticalAlignment="Top" />
Run Code Online (Sandbox Code Playgroud)
我在C#中填充ListPicker,使用列表设置为ItemSource,如果有任何帮助的话.另一件事是,当我尝试在xml中编写"ListPickerMode"时,它会将它作为选项提供,但是当我写完整个内容时它会建议"完全""扩展"和"正常".
如果我向ListPicker添加5个项目,它会自动使用FullMode,我尝试更改ItemCountThreshold ="0",但这只会产生更多错误.
我正在使用Windowns Phone 7.1 OS 2011年8月发布.
可能只是我这是愚蠢的,第一天使用Windows Phone编程:)
UPDATE!
好吧看起来像ItemCountThreshold和ListPickerMode被删除了7.1或者什么,至少在XAML部分,而不是C#部分,它们是只读的.
解决我的问题!
<toolkit:ListPicker x:Name="OutputSelector" ExpansionMode="FullScreenOnly"
Margin="0,542,6,0" Header="Output Type" Width="450" VerticalAlignment="Top" />
Run Code Online (Sandbox Code Playgroud)
ExpansionMode将使Listpicker以全屏显示或展开.
如Silverlight工具包[1]的问题跟踪器中所述,不应设置ItemCountThreshold(并且不能使用简单的xaml设置).
但是,此问题有两种解决方法.如果您不介意使用代码隐藏,请通过SetValue设置属性:
//e.g., in the constructor, just after InitializeComponent();
ListPicker.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 0);
Run Code Online (Sandbox Code Playgroud)
要在xaml中设置值,您可以使用绑定:
<toolkit:ListPicker ItemCountThreshold="{Binding Hugo,FallbackValue=0}">(...)
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我使用伪造的绑定表达式并使用FallbackValue设置值.当然,实际的工作绑定也应该起作用.xaml方法仅在WP8 SDK上进行了测试,但它也适用于7.1.
编辑:刚刚发现xaml方法破坏了设计师.
[1] http://silverlight.codeplex.com/workitem/9742
作者提出的解决方案(移至此处以获得更好的可见性):
嗯,看起来 ItemCountThreshold 和 ListPickerMode 在 7.1 或其他版本中已被删除,至少在 XAML 部分,而不是 C# 部分,它们是只读的。
解决我的问题!
Run Code Online (Sandbox Code Playgroud)<toolkit:ListPicker x:Name="OutputSelector" ExpansionMode="FullScreenOnly" Margin="0,542,6,0" Header="Output Type" Width="450" VerticalAlignment="Top" />
ExpansionMode 将使列表选择器显示为全屏或展开。
归档时间: |
|
查看次数: |
8582 次 |
最近记录: |