我已經爲Windows通用平臺(Win 10 UWP)創建了一個類庫。如何將xbf文件添加到Visual Studio項目
庫存有一些用戶控件。
當我從這個庫中添加DLL到10場UWP的應用程序,並使用用戶控件,它給人的規定here in another question I posted
一個XamlParseException但是,當我引用整個項目,沒有例外,我可以使用UserControl。這種情況的發生應該是因爲在我引用dll文件時,沒有將這些xbf文件添加到Win 10應用程序項目中。
在某個項目,我需要手動添加XBF文件到10場的應用程序的項目,我不能引用整個項目,我只能引用的DLL,並添加所需的文件。
我試圖創建在Visual Studio項目文件夾,並添加XBF文件,並嘗試創建具有不同名稱的文件夾,並通過Windows資源管理器的「bin」目錄中有複製XBF文件。但沒有成功。
所以,我怎麼手冊冊XBF文件添加到Windows 10 UWP項目?
更新1: - XAML &代碼參考
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>
我直接在另一應用程序中使用的控制, -
CustomPopupControl myctrl = new CustomPopupControl();
myctrl.OpenPopup();
你解決了你的問題嗎? –