5

Tôi đang cố gắng lấy mẫu cụ thể trong từ điển tài nguyên của mình. Đây là từ điển tài nguyên của tôiSilverlight 4.0: Lỗi DataTemplate

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:view="clr-namespace:Test.Layout.View" 
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><DataTemplate x:Key="LeftRightLayout"> 
    <toolkit:DockPanel> 
     <view:SharedContainerView toolkit:DockPanel.Dock="Left"/> 
     <view:SingleContainerView toolkit:DockPanel.Dock="Right"/> 
    </toolkit:DockPanel> 
</DataTemplate> 

Tuy nhiên khi nó được cho XamlReader.Load

private static ResourceDictionary GetResource(string resourceName) 
    { 
     ResourceDictionary resource = null; 

     XDocument xDoc = XDocument.Load(resourceName); 
     resource = (ResourceDictionary)XamlReader.Load(xDoc.ToString(SaveOptions.None)); 

     return resource; 
    } 

Loại 'SharedContainerView' không tìm thấy vì 'clr-namespace : Test.Layout.View 'là một không gian tên không xác định. [Dòng: 4 Vị trí: 56]

+0

Tôi gặp vấn đề tương tự. Bạn đã tìm thấy một cách để giải quyết vấn đề này? – Gaby

+0

@Gaby chưa .. – xscape

Trả lời

3

Bạn đã thử thêm một trình phân định lắp ráp vào chế độ xem xmlns: chưa?

3

Bạn nên thêm vòng loại hội đồng vào không gian tên của mình. Ví dụ, nếu tên lắp ráp của bạn là SilverlightApplication1 bạn nên thêm

; lắp ráp = SilverlightApplication1

đến hết namespace của bạn như sau:

xmlns: view = "clr-namespace: Test.Layout.View ; assembly = SilverlightApplication1 "

Các vấn đề liên quan