【问题标题】:Error HRESULT E_FAIL has been returned from a call to a COM component in Windows Phone对 Windows Phone 中的 COM 组件的调用已返回错误 HRESULT E_FAIL
【发布时间】:2013-08-14 11:17:47
【问题描述】:

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

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

【问题讨论】:

  • 你的 xaml 中是否有任何错误。因为我没有得到你的 DIgitLoopimgSelector 是什么,因为在 wp8 thr 中 loopingSelector 不是 digitloopingSelector ..如果我错了请评论
  • 这些错误是由于错误的xaml ..希望现在你解决你的问题..
  • 对不起,xaml 不完全是问题。我查过了。
  • Text="{Binding BindsDirectlyToSource=True}" 这是什么..
  • 当我单击此选择器时,屏幕上会出现从 1 到 15 的值范围,就像 datepicker 一样滚动。因此,在这个 digitloopingselector 中,会采用一个文本框,并将所选项目绑定到该文本框。

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


【解决方案1】:

问题是,我正在开发 wp8 应用程序,而我采用的 DigitLoopingSelector 控件属于旧版本。只需右键单击项目并将属性>目标Windows Phone OS版本更改为OS 8.0即可解决问题。

【讨论】:

    猜你喜欢
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-06
    • 2019-07-03
    • 2013-09-09
    相关资源
    最近更新 更多