【问题标题】:Upgrading wp8 to wp8.1 silverlight, Listpicker error upon initialize component将 wp8 升级到 wp8.1 silverlight,初始化组件时出现 Listpicker 错误
【发布时间】:2015-07-19 10:53:44
【问题描述】:

升级到 Wp8.1 silverlight 后,我​​的列表选择器在运行时失败,此时执行 InitializeComponent();

listpicker 来自的 WPtoolKit 已经更新,但在我的解决方案中仍然是:\packages\WPtoolkit.4.2013.08.16\lib\wp8\Microsoft.Phone.Controls.Toolkit.dll

列表选择器显示在xaml设计视图中,代码为:

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
.
.
.
<StackPanel Grid.Row="0" Grid.RowSpan="3"  Orientation="Horizontal" >
        <toolkit:ListPicker x:Name="LP_Map" Width="284" Template="{StaticResource ListPicker_ChooseCountry_CreateGame_test}" BorderBrush="#FF884900">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding ChangeMapCommand}" CommandParameter="{Binding ElementName=LP_Map}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <toolkit:ListPickerItem Background="#FFAB7D33" Content="Europe1328WithWater" Foreground="Black" Style="{StaticResource ListPickerItem_CreateGame_ChooseCountry_test}" />
        </toolkit:ListPicker>

        <toolkit:ListPicker x:Name="Player_LP" Width="150" SelectionChanged="SelChangedCommand" BorderBrush="#FF884900" Foreground="Black">
            <toolkit:ListPickerItem Background="#FFAB7D33" Content="2 Players" Foreground="Black" FontFamily="Andalus" />
            <toolkit:ListPickerItem Background="#FFAB7D33" Content="3 Players" FontFamily="Andalus" />
            <toolkit:ListPickerItem Background="#FFAB7D33" Content="4 Players" FontFamily="Andalus" />
        </toolkit:ListPicker>
    </StackPanel>

我不明白为什么我会收到 XAML 解析错误,在重新定位解决方案后,我是否需要明确更新或更改某些内容?

注意 使用 MVVMLight 的 EventToCommand 不是问题,这已更新为使用参数包。

【问题讨论】:

    标签: c# silverlight mvvm windows-phone-8.1 listpicker


    【解决方案1】:

    ComboBox 在 Windows Phone 8.1 Silverlight 中不可用。

    我目前正在使用最新版本的 WP phonetoolkit 开发 WP8.1 Silverlight 解决方案。使用 ListPicker 没有问题。这是一个例子:

    xmlns:Local="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    
    <toolkit:ListPicker
                        x:Name="MyListBox"
                        BorderBrush="{StaticResource AppBackground}"
                        Foreground="{StaticResource AppTextColor}"
                        ItemsSource="{Binding Categories}">
                        <Local:Interaction.Triggers>
                            <Local:EventTrigger EventName="SelectionChanged">
                                <Local:InvokeCommandAction Command="{Binding DataContext.OpenCategoryCMD, ElementName=LayoutRoot}"
                                                       CommandParameter="{Binding ElementName=MyListBox, Path=SelectedIndex}"/>
                            </Local:EventTrigger>
                        </Local:Interaction.Triggers>
                    </toolkit:ListPicker>
    

    在 ViewModel 中:

    private void OpenCategory(int categoryIndex) { ... }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 1970-01-01
      • 2020-11-29
      相关资源
      最近更新 更多