无法在 Blend 中显示 AutoCompleteBox

发布于 2024-12-03 16:51:07 字数 339 浏览 10 评论 0原文

我遇到了 Autocompletebox 控件的问题,该控件在 Blend 中不起作用,它抱怨 InputScope 属性的 TypeConverter 无法从字符串进行转换。该控件在运行时工作正常,并且在 VS2010 设计器中显示良好。

有没有一种简单的方法可以完全禁用该控件或仅在设计时将其替换为简单的文本块?

更好的是有人知道我如何让 AutoCompleteBox 按原样在混合中工作吗?

编辑: 我发现,如果我只删除 InputScope 属性的设置,则 AutoCompleteBox 显示正常。那么,在设计模式下,如何以编程方式删除 XAML (InputScope="Search") 的那部分呢?

I have a problem with the Autocompletebox control which doesn't work in Blend which complains that the TypeConverter for the InputScope property cannot convert from a string. The control works fine at run time and displays fine in the VS2010 designer.

Is there an easy way can either just disable the control entirely or swap it out for a simple textblock at design time only?

Better still does anyone know how I could just make the AutoCompleteBox work in blend as is?

Edit:
I've found that if I just remove the setting of the InputScope property then the AutoCompleteBox displayes fine. So how can I programaticly remove just that portion of the XAML (InputScope="Search") when in design mode?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风启觞 2024-12-10 16:51:07

这很奇怪,在我为这个控件创建了默认样式后,它不再向我抛出任何错误......而且我不知道为什么......我认为这是一个错误。 :)

    <Style TargetType="toolkit:AutoCompleteBox">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentControl Content="{Binding}" Margin="8,7"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Padding" Value="6,0,6,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:AutoCompleteBox">
                    <Grid>
                        <TextBox x:Name="Text" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" InputScope="{TemplateBinding InputScope}" Opacity="{TemplateBinding Opacity}" Padding="{TemplateBinding Padding}" Style="{TemplateBinding TextBoxStyle}"/>
                        <Popup x:Name="Popup">
                            <ListBox x:Name="Selector" BorderBrush="{StaticResource PhoneTextBoxEditBorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="White" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" IsTabStop="False" ItemTemplate="{TemplateBinding ItemTemplate}" ItemContainerStyle="{TemplateBinding ItemContainerStyle}" Opacity="{TemplateBinding Opacity}" Padding="0,8"/>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

It's weird, after I created a default style for this control, it doesn't throw me any error anymore... And I have no idea why... I think it is a bug. :)

    <Style TargetType="toolkit:AutoCompleteBox">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentControl Content="{Binding}" Margin="8,7"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Padding" Value="6,0,6,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:AutoCompleteBox">
                    <Grid>
                        <TextBox x:Name="Text" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" InputScope="{TemplateBinding InputScope}" Opacity="{TemplateBinding Opacity}" Padding="{TemplateBinding Padding}" Style="{TemplateBinding TextBoxStyle}"/>
                        <Popup x:Name="Popup">
                            <ListBox x:Name="Selector" BorderBrush="{StaticResource PhoneTextBoxEditBorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="White" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" IsTabStop="False" ItemTemplate="{TemplateBinding ItemTemplate}" ItemContainerStyle="{TemplateBinding ItemContainerStyle}" Opacity="{TemplateBinding Opacity}" Padding="0,8"/>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
淡淡的优雅 2024-12-10 16:51:07

事实证明这非常简单。

只需在要忽略的属性中添加 mc:Ignorable 前缀即可。
http://msdn.microsoft.com/en-us/library/aa350024.aspx

换句话说,只需在 InputScope 属性前加上 d 前缀即可:

<toolkit:AutoCompleteBox d:InputScope="Search"/>

Turns out it is incredibly easy.

Just add the mc:Ignorable prefix to the attribute to be ignored.
http://msdn.microsoft.com/en-us/library/aa350024.aspx

In other words just prefix the InputScope attribute with d:

<toolkit:AutoCompleteBox d:InputScope="Search"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文