• <bdo id='joOyE'></bdo><ul id='joOyE'></ul>
    <i id='joOyE'><tr id='joOyE'><dt id='joOyE'><q id='joOyE'><span id='joOyE'><b id='joOyE'><form id='joOyE'><ins id='joOyE'></ins><ul id='joOyE'></ul><sub id='joOyE'></sub></form><legend id='joOyE'></legend><bdo id='joOyE'><pre id='joOyE'><center id='joOyE'></center></pre></bdo></b><th id='joOyE'></th></span></q></dt></tr></i><div id='joOyE'><tfoot id='joOyE'></tfoot><dl id='joOyE'><fieldset id='joOyE'></fieldset></dl></div>
    <tfoot id='joOyE'></tfoot>
    <legend id='joOyE'><style id='joOyE'><dir id='joOyE'><q id='joOyE'></q></dir></style></legend>

    1. <small id='joOyE'></small><noframes id='joOyE'>

        如何将 xbf 文件添加到 Visual Studio 项目

        How to add xbf files to visual studio project(如何将 xbf 文件添加到 Visual Studio 项目)

              <tbody id='ik2kD'></tbody>

              • <bdo id='ik2kD'></bdo><ul id='ik2kD'></ul>
                • <tfoot id='ik2kD'></tfoot>
                  <i id='ik2kD'><tr id='ik2kD'><dt id='ik2kD'><q id='ik2kD'><span id='ik2kD'><b id='ik2kD'><form id='ik2kD'><ins id='ik2kD'></ins><ul id='ik2kD'></ul><sub id='ik2kD'></sub></form><legend id='ik2kD'></legend><bdo id='ik2kD'><pre id='ik2kD'><center id='ik2kD'></center></pre></bdo></b><th id='ik2kD'></th></span></q></dt></tr></i><div id='ik2kD'><tfoot id='ik2kD'></tfoot><dl id='ik2kD'><fieldset id='ik2kD'></fieldset></dl></div>
                  <legend id='ik2kD'><style id='ik2kD'><dir id='ik2kD'><q id='ik2kD'></q></dir></style></legend>

                  <small id='ik2kD'></small><noframes id='ik2kD'>

                • 本文介绍了如何将 xbf 文件添加到 Visual Studio 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经为 Windows 通用平台(Win 10 UWP)创建了一个类库.

                  该库包含一些用户控件.

                  当我将此库中的 dll 添加到 Win 10 UWP 应用程序并使用 UserControls 时,它会给出 XamlParseException,如

                  我们需要参考的文件:

                  • ClassLibrary1(类库名称)文件夹
                    • ClassLibrary1.xr.xml
                    • CustomPopupControl.xaml
                  • ClassLibrary1.dll
                  • ClassLibrary1.pri -> 包资源索引文件

                  将这些文件复制到任何地方,UWP项目只需在Visual Studio中添加对ClassLibrary1.dll文件的引用,它们都会自动添加.

                  <块引用>

                  当我尝试在InitializeComponent()"方法上使用 UserControl 时,它只会引发 xaml 解析异常

                  添加引用时可能缺少 .pri 文件.

                  I have created a class library for Windows Universal Platform (Win 10 UWP).

                  The library houses some UserControls.

                  When I add the dll from this library to a Win 10 UWP app, and use the UserControls, it gives a XamlParseException as stated here in another question I posted

                  But when I reference the whole project, there is no exception and I can use the UserControl. This happens supposedly because there are xbf files which are not added to the Win 10 app project when I just reference the dll file.

                  In a certain project, I need to add the xbf files manually to the Win 10 app project, I cannot reference the whole project, I can only reference the dll and add the required files.

                  I tried creating a folder in Visual Studio project and adding the xbf files, and also tried creating folders with different names and copying the xbf files there in the "bin" directory through windows explorer. But no success.

                  So, how do I manuall add xbf files to a Windows 10 UWP project?

                  Update 1 :- XAML & Code for reference

                  public sealed partial class CustomPopupControl : UserControl
                  {
                      internal CustomPopupControl()
                      {
                          this.InitializeComponent();    //-------CRASHES HERE-------
                      }
                  
                      internal CustomPopupControl() : base()
                      {
                          Debug.WriteLine("CustomPopupControl");
                          //
                          //do some stuff
                          //
                          //
                      }
                  
                      private void OnPopupLoaded(object sender, RoutedEventArgs e)
                      {
                          this.Popup_Container.HorizontalOffset = (Window.Current.Bounds.Width - Grid_Child.ActualWidth) / 2;
                          this.Popup_Container.VerticalOffset = (Window.Current.Bounds.Height - Grid_Child.ActualHeight) / 2;
                      }
                  
                      internal void OpenPopup()
                      {
                          Debug.WriteLine("OpenPopup");
                          Popup_Container.IsOpen = true;
                  
                          var currentFrame = Window.Current.Content as Frame;
                          var currentPage = currentFrame.Content as Page;
                          currentPage.IsHitTestVisible = false;
                  
                          Debug.WriteLine("OpenPopup Done");
                      }
                  
                      private void OnLayoutUpdated(object sender, object e)
                      {
                          if (Grid_Child.ActualWidth == 0 && Grid_Child.ActualHeight == 0)
                          {
                              return;
                          }
                  
                          double ActualHorizontalOffset = Popup_Container.HorizontalOffset;
                          double ActualVerticalOffset = Popup_Container.VerticalOffset;
                  
                          double NewHorizontalOffset = (Window.Current.Bounds.Width - Grid_Child.ActualWidth) / 2;
                          double NewVerticalOffset = (Window.Current.Bounds.Height - Grid_Child.ActualHeight) / 2;
                  
                          if (ActualHorizontalOffset != NewHorizontalOffset || ActualVerticalOffset != NewVerticalOffset)
                          {
                              Popup_Container.HorizontalOffset = NewHorizontalOffset;
                              Popup_Container.VerticalOffset = NewVerticalOffset;
                          }
                      }
                  }
                  

                  XAML :-

                  <UserControl
                  x:Class="MyLibrary.CustomPopupControl"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:local="using:MyLibrary"
                  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">
                  
                  <Popup Name="Popup_Container" LayoutUpdated="OnLayoutUpdated">
                      <Border BorderThickness="1" BorderBrush="{ThemeResource AppBarBorderThemeBrush}">
                          <Grid Name="Grid_Child">
                              <Grid Name="Grid_Content"  Height="300" Width="400" />
                          </Grid>
                      </Border>
                  </Popup>
                  

                  I use the control directly in another app, as -

                  CustomPopupControl myctrl = new CustomPopupControl();
                  myctrl.OpenPopup();
                  

                  解决方案

                  In addition to Thomas's answer, you need to check the "Generate library layout" option in the Build configuration under the project's Properties page.

                  The files we need to reference:

                  • ClassLibrary1(Class Library name) Folder
                    • ClassLibrary1.xr.xml
                    • CustomPopupControl.xaml
                  • ClassLibrary1.dll
                  • ClassLibrary1.pri -> Package Resource Index file

                  Copy these files to anywhere and the UWP project just need to add reference to the ClassLibrary1.dll file in the Visual Studio, all of them will be added automatically.

                  It just throws a xaml parse exception when I try to use the UserControl on the "InitializeComponent()" method

                  Perhaps the .pri file is missing when you add the reference.

                  这篇关于如何将 xbf 文件添加到 Visual Studio 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)
                      <bdo id='fytM6'></bdo><ul id='fytM6'></ul>

                      <small id='fytM6'></small><noframes id='fytM6'>

                        <tbody id='fytM6'></tbody>

                      1. <i id='fytM6'><tr id='fytM6'><dt id='fytM6'><q id='fytM6'><span id='fytM6'><b id='fytM6'><form id='fytM6'><ins id='fytM6'></ins><ul id='fytM6'></ul><sub id='fytM6'></sub></form><legend id='fytM6'></legend><bdo id='fytM6'><pre id='fytM6'><center id='fytM6'></center></pre></bdo></b><th id='fytM6'></th></span></q></dt></tr></i><div id='fytM6'><tfoot id='fytM6'></tfoot><dl id='fytM6'><fieldset id='fytM6'></fieldset></dl></div>
                      2. <tfoot id='fytM6'></tfoot>

                            <legend id='fytM6'><style id='fytM6'><dir id='fytM6'><q id='fytM6'></q></dir></style></legend>