Search code examples
silverlightwindows-phone-7expression-blend

Cannot display the AutoCompleteBox in Blend


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?


Solution

  • 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>