在Tablet上使用x:DataType时,ComboBox会抛出XamlParseException [英] ComboBox throws XamlParseException when using x:DataType on Tablet

查看:73
本文介绍了在Tablet上使用x:DataType时,ComboBox会抛出XamlParseException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个用户可以从ComboBox中选择的应用程序。

I'm currently working on a application where the user can select from a ComboBox.

在我的机器上进行一些测试后,我将应用程序安装在SurfaceBook和HP-Tablet上。在机器和SurfaceBook上,带有下拉列表的页面打开没有任何问题,但在HP-Tablet上页面会在this.InitilizeComponents上抛出XamlParseException。

After some test on my machine I installed the application on a SurfaceBook and on a HP-Tablet. On both machine and SurfaceBook the page with the dropdown opens without any problems but on the HP-Tablet the page throws an XamlParseException on this.InitilizeComponents.

经过一些挖掘和测试后,我发现问题是x:Bing和x:DataType。

After some digging and testing I found that the problem is the x:Bing and the x:DataType.

在我的例子中,类型是一个简单的字符串。

In my example the type is a simple string.

这有效:

<ComboBox 
            x:Name="cbComType"
            Grid.Row="1"
            Margin="0,10,0,0"
            SelectedIndex="0"
            ItemsSource="{Binding Values, Mode=OneWay}"
            SelectionChanged="cbComType_SelectionChanged"
            >
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

这不起作用:

<ComboBox 
            x:Name="cbComType"
            Grid.Row="1"
            Margin="0,10,0,0"
            SelectedIndex="0"
            ItemsSource="{x:Bind Values, Mode=OneWay}"
            SelectionChanged="cbComType_SelectionChanged"
            >
            <ComboBox.ItemTemplate>
                <DataTemplate x:DataType="x:String">
                    <TextBlock Text="{x:Bind}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

提前致谢。

祝你好运

Sebastian

Sebastian

推荐答案

完成所有可用更新后,ComboBox上的x:Bing工作正常。但由于应用程序的
Minum version
是2017年发布的 Fall Creator ,我认为这款平板电脑的Windows版本不比2018年8月更早。 b $ b

After doing all available updates the x:Bing on ComboBox worked. But since Minum version of the application is Fall Creator which was released 2017 and I don't think that the tablet's windows version was older than August 2018.

我可能需要知道如何解决这个问题。或者我应该简单地将代码切换为
Binding?

I may need to know how to solve this problem. Or should I simply switch the code to Binding?

祝你好运

Sebastian Poetschulat

Sebastian Poetschulat


这篇关于在Tablet上使用x:DataType时,ComboBox会抛出XamlParseException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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