a.xaml文件:
<Page x:Class="MyWpfTest.Page3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyWpfTest"
Title="Page3" Loaded="Page_Loaded">
<Page .Resources>
<model:Ca x:Key="Ca1"/>
</Page .Resources>
<Grid Name="gRoot">
</Grid>
</Page>
a.xaml.cs文件:
using TestModel;namespace MyWpfTest
{
/// <summary>
/// Interaction logic for Page3.xaml
/// </summary>
public partial class Page3 : Page
{
public Page3()
{
InitializeComponent();
} private void Page_Loaded(object sender, RoutedEventArgs e)
{
TestModel.Ca c = new TestModel.Ca();
}
}
}
类库文件
b.cs
namespace TestModel
{
public class Ca
{
}
}
问题是想在页面中引用并不在同一个命名空间的类Ca.已经添加了引用,但是只是后台正常,前台不知道怎么办,如果在同一个命名空间,
可以用xmlns:model="clr-namespace:MyWpfTest.Model"
但是如果不在,应该如何处理,各位大侠遇到这个问题该怎么办?
<Page x:Class="MyWpfTest.Page3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyWpfTest"
Title="Page3" Loaded="Page_Loaded">
<Page .Resources>
<model:Ca x:Key="Ca1"/>
</Page .Resources>
<Grid Name="gRoot">
</Grid>
</Page>
a.xaml.cs文件:
using TestModel;namespace MyWpfTest
{
/// <summary>
/// Interaction logic for Page3.xaml
/// </summary>
public partial class Page3 : Page
{
public Page3()
{
InitializeComponent();
} private void Page_Loaded(object sender, RoutedEventArgs e)
{
TestModel.Ca c = new TestModel.Ca();
}
}
}
类库文件
b.cs
namespace TestModel
{
public class Ca
{
}
}
问题是想在页面中引用并不在同一个命名空间的类Ca.已经添加了引用,但是只是后台正常,前台不知道怎么办,如果在同一个命名空间,
可以用xmlns:model="clr-namespace:MyWpfTest.Model"
但是如果不在,应该如何处理,各位大侠遇到这个问题该怎么办?
[code=XAML]
<Page x:Class="WpfApplication1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:TestModel="clr-namespace:TestModel"
Title="Page1" Loaded="Page_Loaded">
<Page.Resources>
<TestModel:Ca x:Key="Ca1"/>
</Page.Resources>
<Grid Name="gRoot">
</Grid>
</Page>[/code]
老兄帮忙仔细看看