2017-02-20 39 views
0

我更新了Xamarin項目中的Xamarin Forms。現在這個代碼不再工作了。Xamarin 2.3.3.193和ItemTemplate

var view = (View)ItemTemplate.CreateContent(); 
if (view != null) { 
    var bindableObject = view as BindableObject; 
    if (bindableObject != null) 
     bindableObject.BindingContext = newItem; 
    _imageStack.Children.Add(view); 
} 

的問題是(View)ItemTemplate.CreateContent()進去錯誤:

Message: Can't resolve name on Element

Source: Xamarin.Forms.Xaml

Stack: at Xamarin.Forms.Xaml.ReferenceExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x000b6] in [...]

調試窗口我可以看到如下的信息

02-20 17:44:04.450 I/art  (13331): Starting a blocking GC Explicit 
02-20 17:44:04.482 I/art  (13331): Explicit concurrent mark sweep GC freed 436(24KB) AllocSpace objects, 0(0B) LOS objects, 21% free, 14MB/18MB, paused 762us total 31.310ms 
02-20 17:44:04.482 I/System (13331): FinalizerDaemon: finalize objects = 48 
02-20 17:44:04.484 D/Mono (13331): GC_TAR_BRIDGE bridges 20 objects 20 opaque 0 colors 20 colors-bridged 20 colors-visible 20 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.11ms tarjan 0.06ms scc-setup 0.08ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.30ms 
02-20 17:44:04.484 D/Mono (13331): GC_BRIDGE: Complete, was running for 34.10ms 
02-20 17:44:04.484 D/Mono (13331): GC_MINOR: (Nursery full) time 4.22ms, stw 4.53ms promoted 32K major size: 3504K in use: 2748K los size: 6404K in use: 5406K 

我的功能在內存中保存的圖像從相機ImageSource格式,byte[]length in byte這張圖片。

回答

0

這表示您正在加載的XAML包含{x:Reference foo}標記擴展名,並且在運行時在層次結構中未找到使用x:Name="foo"定義的元素。

在沒有看到您的XAML的情況下,無法確定問題出在您的代碼中,還是出現在Xamarin.Forms中的錯誤。

+0

謝謝,我知道我必須搜索我的錯誤。 – Enrico