Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows应用商店应用程序-灾难性故障(HRESULT异常:0x8000FFFF(E_意外))_C#_User Controls_Windows Store Apps_Windows Store - Fatal编程技术网

C# Windows应用商店应用程序-灾难性故障(HRESULT异常:0x8000FFFF(E_意外))

C# Windows应用商店应用程序-灾难性故障(HRESULT异常:0x8000FFFF(E_意外)),c#,user-controls,windows-store-apps,windows-store,C#,User Controls,Windows Store Apps,Windows Store,我正试图用C#编写一个小型库,将一些类和UI元素重用到不同的项目中 我想放在这个库中的UI元素是一个非常简单的UserControl: <UserControl x:Class="MyProjet.UiUtil.Progress" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml

我正试图用C#编写一个小型库,将一些类和UI元素重用到不同的项目中

我想放在这个库中的UI元素是一个非常简单的UserControl:

<UserControl
    x:Class="MyProjet.UiUtil.Progress"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyProjet.UiUtil"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <UserControl.Resources>
        <Style x:Key="BasicTextStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="{StaticResource ApplicationForegroundThemeBrush}"/>
            <Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}"/>
            <Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}"/>
            <Setter Property="TextTrimming" Value="WordEllipsis"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
            <Setter Property="Typography.StylisticSet20" Value="True"/>
            <Setter Property="Typography.DiscretionaryLigatures" Value="True"/>
            <Setter Property="Typography.CaseSensitiveForms" Value="True"/>
        </Style>

        <Style x:Key="BaselineTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BasicTextStyle}">
            <Setter Property="LineHeight" Value="20"/>
            <Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
            <!-- Aligne correctement le texte sur sa ligne de base -->
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TranslateTransform X="-1" Y="4"/>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="HeaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
            <Setter Property="FontSize" Value="56"/>
            <Setter Property="FontWeight" Value="Light"/>
            <Setter Property="LineHeight" Value="40"/>
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TranslateTransform X="-2" Y="8"/>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="SubheaderTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}">
            <Setter Property="FontSize" Value="26.667"/>
            <Setter Property="FontWeight" Value="Light"/>
            <Setter Property="LineHeight" Value="30"/>
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TranslateTransform X="-1" Y="6"/>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="GridRoot" Width="{Binding Path=GridWidth}" Height="{Binding Path=GridHeight}" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>            

        <TextBlock x:Name="TxtTitle" Grid.Row="0" Text="{Binding Path=Title}" Style="{StaticResource HeaderTextStyle}" TextAlignment="Center" TextWrapping="Wrap" Margin="12,12,12,0" VerticalAlignment="Center" HorizontalAlignment="Center" />

        <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
            <TextBlock x:Name="TxtDescription" Text="{Binding Path=Description}" TextAlignment="Center" Style="{StaticResource SubheaderTextStyle}" TextWrapping="Wrap" />
            <ProgressBar IsIndeterminate="True" Margin="0, 15" Width="350" />
        </StackPanel>
    </Grid>
</UserControl>
当我将UserControl文件复制到示例项目中时,一切正常,但当我使用库中的UserControl(包作为nuget依赖项)时出现问题,我有以下错误消息和代码:

灾难性故障(HRESULT异常:0x8000FFFF (E_)

未处理Windows.UI.Xaml.Controls.Frame.NavigationFailed

我在互联网上看到,评论或取消注释这一行有助于:

base.OnNavigatedTo(e);
就我而言,它不会改变任何事情

希望有人能帮助我


提前告诉你

我的错误似乎与此主题有关:

当我收到此错误时(没有其他内部异常)-它链接到
列表视图中的
dsiplaymberpath
属性。删除此项会使其再次工作

它似乎有一个类似的问题,没有明确的原因,这导致了一个错误


作为一种解决方法,我覆盖了model对象上的
ToString
方法,以显示我想要的属性。

将重点放在灾难上,而更多地放在“导航失败”消息上。正在导航到什么?显示堆栈跟踪。听起来像usercontrol中的XAML错误。尝试一次删除一段XAML代码以缩小错误范围。
using System;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace SampleProject
{
    public sealed partial class MainPage
    {
        private Popup _popup;

        private DispatcherTimer _timer;

        public MainPage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            _popup = new Popup() { Child = new Progress("Mon Titre", "Ma description", new SolidColorBrush(Colors.Magenta), new SolidColorBrush(Colors.Green), new SolidColorBrush(Colors.Orange)), IsOpen = false };
            _timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(5) };
            _timer.Tick += timer_Tick;
        }

        private void timer_Tick(object sender, object e)
        {
            _timer.Stop();
            _popup.IsOpen = false;
            BtnDisplay.IsEnabled = true;
        }

        private void BtnDisplay_Click(object sender, RoutedEventArgs e)
        {
            BtnDisplay.IsEnabled = false;
            _timer.Start();
            _popup.IsOpen = true;
        }
    }
}
base.OnNavigatedTo(e);