我刚刚安装了vs2013,我在此环境下进行了之前使用VS2010开发的WPF项目。发生了一件非常奇怪的事情,显然2010年没有发生....我有自己的自定义控件,它定义了字典的运行时URI ...奇怪的是,在xaml页面的代码中,当我定义了我的控件的使用,我已经在主题中报告了错误,但是如果我开始使用dubug,一切正常并且样式正确应用....有人有想法吗?
代码看起来像这样:
自定义控件
using System;
using System.Windows.Controls;
using System.Windows;
using System.ComponentModel;
using System.Windows.Data;
namespace myListView
{
public class myListView : ListView
{
// ... some dependency property
protected override void OnInitialized(EventArgs e)
{
Uri uri = new Uri("Skins\\myDictionary.xaml", UriKind.Relative);
dictionary = Application.LoadComponent(uri) as ResourceDictionary;
//... rest of code
base.OnInitialized(e);
}
}
}
xaml页面
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xlw="clr-namespace:myListView;assembly=myListView"
Title="MainWindow" Height="350" Width="525">
<Grid>
<xlw:myListView>
<!-- the editor tell me that can't find the Skins/myDictionary.xaml -->
</xlw:myListView>
</Grid>
</Window>