主題\ Generic.xaml:WPF - 資源不是來自Generic.xaml加載
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="WPF Commons;component/Controls/Layout/Foo/FooItem.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
控制\佈局\富\ FooItem.xaml:
<Style TargetType="{x:Type l:FooItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type l:FooItem}">
<Border>
<ContentPresenter ContentSource="Header" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如果我將整個樣式複製到我的usercontrol資源中,它工作正常。但是,如果我不這樣做,用戶控件顯示爲空。在Expression Blend 4中,我右鍵單擊並選擇了Edit Template
>,但它不會讓我選擇Edit a Copy...
,這導致我認爲某些內容嚴重錯誤,並且Generic.xaml未正確加載。我認爲它是Generic.xaml,因爲如果我刪除MergedDictionary調用並將xaml樣式直接複製/粘貼到Generic.xaml中,它仍然不起作用。
您還可以擴大(下拉)在Solution Explorer中的特殊屬性節點,然後打開AssemblyInfo.cs中和添加上面的東西,你能告訴你的FooItem代碼?通常,UserControls不應該被重新設計(即設置Template屬性),因爲它不能按預期工作。 – CodeNaked 2011-04-12 17:15:57
FooItem.cs現在爲空,我想確保自己的佈局正確並稍後在其他DependencyProperties和邏輯中緩慢添加。 – michael 2011-04-12 17:24:10
FooItem從何而來? – CodeNaked 2011-04-12 17:30:09