错误HRESULT E_FAIL已从Windows Phone中的COM组件调用返回

时间:2013-08-14 11:17:48

标签: .net xaml windows-phone-7 windows-phone-8

我正在开发一款需要DigitLoopingSelector的应用。添加DigitLoopingSelector并运行程序后,我收到错误“错误HRESULT E_FAIL已从调用COM组件返回。”为什么我在WIndows Phone8中收到此错误? DigitLoopingSelector的工作方式类似于datepicker,范围从我自己的一组值中选择。

//xaml code
<phone:PhoneApplicationPage
    x:Class="Jogger.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     
    xmlns:my="clr-namespace:Controls.Primitives;assembly=Controls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

//code for DigitLoopingSelector


                <Grid x:Name="WidthPanel" Grid.Row="1" VerticalAlignment="Center" Height="258" Width="480"  >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.3*"/>
                        <ColumnDefinition Width="0.1*"/>
                        <ColumnDefinition Width="0.30*"/>
                        <ColumnDefinition Width="0.2*"/>
                    </Grid.ColumnDefinitions>

                    <my:DigitLoopingSelector 
                Grid.Column="0"
                Name="WidthMeterSelector" 
        ItemSize="108,108"
        ItemMargin="6,3" HorizontalAlignment="Right" Margin="0" Width="108" IsExpanded="True"
                MaxValue="15" MinValue="1" DefaultValue="3"  SelectedItem="{Binding WidthMeter}" >
                        <my:DigitLoopingSelector.ItemTemplate>
                            <DataTemplate>
                                <TextBlock 
                Text="{Binding BindsDirectlyToSource=True}" 
                FontSize="54" TextAlignment="Center" VerticalAlignment="Center"
                FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
                            </DataTemplate>
                        </my:DigitLoopingSelector.ItemTemplate>
                    </my:DigitLoopingSelector>

                    <TextBlock Grid.Column="1" Margin="0,0,0,0" TextWrapping="Wrap" Text="m" FontSize="48" VerticalAlignment="Center"/>
                    <my:DigitLoopingSelector 
                Grid.Column="2"
                Name="WidthCentimeterSelector" 
        ItemSize="108,108"
        ItemMargin="6,3" 
                MaxValue="99" StringFormat="D2"
                MinValue="0" HorizontalAlignment="Right" Margin="48,0,0,0" Width="108" IsExpanded="True" 
                >
                        <my:DigitLoopingSelector.ItemTemplate>
                            <DataTemplate>
                                <TextBlock 
                Text="{Binding BindsDirectlyToSource=True}" x:Name="secondText"
                FontSize="54" TextAlignment="Center" VerticalAlignment="Center"
                FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
                            </DataTemplate>
                        </my:DigitLoopingSelector.ItemTemplate>
                    </my:DigitLoopingSelector>
                    <TextBlock Grid.Column="3" Margin="0" TextWrapping="Wrap" Text="cm" FontSize="48" VerticalAlignment="Center"/>
                </Grid>

1 个答案:

答案 0 :(得分:4)

问题是,我正在研究wp8应用程序和我采用的DigitLoopingSelector控件属于旧版本。只需右键单击项目并更改属性&gt;将Windows Phone OS版本定位到OS 8.0,问题解决了。