[UWP] [C#] PivotItem的后代在更新到构建17025.1000后抛出InvalidComObjectException [英] [UWP][C#] Descendant of PivotItem throws InvalidComObjectException after update to build 17025.1000

查看:53
本文介绍了[UWP] [C#] PivotItem的后代在更新到构建17025.1000后抛出InvalidComObjectException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需创建后代实例并获取异常:  InvalidComObjectException

Just create instance of descendant and get the exception: InvalidComObjectException



附加信息:尝试使用COM对象没有支持类工厂。


Additional information: Attempt has been made to use a COM object that does not have a backing class factory.

    public sealed partial class MainPage : Page {
        public MainPage() {
            this.InitializeComponent();
            var pivotItem = new MyPivotItem();
        }
    }
    public class MyPivotItem : PivotItem { }

推荐答案

嗨john burt 20

这些都是代码吗?如果您没有任何其他代码,原因是 
问题可能没有自定义< pivotItem>的样式。  您可以添加< pivotItem> app.xaml中的样式并将目标更改为< MyPivotItem>。您可以参考以下代码


<Application.Resources>
        <!-- Default style for Windows.UI.Xaml.Controls.PivotItem -->
        <Style TargetType="local:MyPivotItem">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Margin" Value="{ThemeResource PivotItemMargin}"/>
            <Setter Property="Padding" Value="0" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Stretch" />
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="PivotItem">
                        <Grid Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="Pivot">
                                    <VisualState x:Name="Right" />
                                    <VisualState x:Name="Left" />
                                    <VisualState x:Name="Center" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>




< span style ="font-size:9.5pt; font-family:Consolas; color:blue">

如果您已添加样式,请提供您使用的所有代码?
我最好找出问题的原因。

祝你好运,

Roy


这篇关于[UWP] [C#] PivotItem的后代在更新到构建17025.1000后抛出InvalidComObjectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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