你可以通過以下兩種方式中的任何一種。一個是加載和初始化的WPF基礎設施:
Add-Type -AssemblyName PresentationFramework,PresentationCore
[windows.application]::current > $null # Inits the pack protocol
new-object system.uri("pack://application:,,,/WPFResource;component/test.xaml")
另一種方式是手工註冊包協議:
$opt = [GenericUriParserOptions]::GenericAuthority
$parser = new-object system.GenericUriParser $opt
if (![UriParser]::IsKnownScheme("pack")) {
[UriParser]::Register($parser,"pack",-1)
}
new-object system.uri("pack://application:,,,/WPFResource;component/test.xaml")
很好的問題。如果您嘗試將程序集資源應用於您的窗口,我將http://msdn.microsoft.com/en-us/library/aa970069.aspx中的示例粘貼到C#中也會出現同樣的錯誤 – 2010-10-20 08:53:41
,我認爲您可以添加對dll的引用並在app.xaml中創建一個與此類似的資源字典:; /resource.xaml」/> –
foureight84
2010-10-20 09:02:46