2014-04-07 30 views
11

Bir MapTileSource ürününün DataSource'ını görünüm modelimdeki bir özelliğe bağlamaya çalışıyorum, ancak REGDB_E_CLASSNOTREG dosyasının Haritalar: MapTileSource satırında (mavi renkte altı çizili VS düzenleyicisidir) hata alıyorum. . Aynı etkiyi elde etmek için her zaman bağlayıcılı bir yardımcı kullanabilirim (uygulamamın 8.0 sürümüne ihtiyacım vardı), ancak bu sadece işe yaramalı gibi görünüyor. Neyin yanlış olduğuyla ilgili bir fikriniz var mı?Windows Phone 8.1 MVVM ile MapTileSource ciltleme

<Maps:MapControl Style="{Binding Path=MapStyle}" Center="{Binding Path=MapCenter, Mode=TwoWay}" ZoomLevel="{Binding Path=ZoomLevel, Mode=TwoWay}" MapServiceToken=""> 
    <Maps:MapControl.TileSources> 
     <Maps:MapTileSource Layer="BackgroundReplacement" DataSource="{Binding Path=BaseLayerDataSource}" /> 
    </Maps:MapControl.TileSources> 
</Maps:MapControl> 

Ben de aynı etkiye sahip sadece statik bir veri kaynağıyla çalıştı:

<Maps:MapControl Style="{Binding Path=MapStyle}" Center="{Binding Path=MapCenter, Mode=TwoWay}" ZoomLevel="{Binding Path=ZoomLevel, Mode=TwoWay}" MapServiceToken=""> 
    <Maps:MapControl.TileSources> 
     <Maps:MapTileSource Layer="BackgroundReplacement"> 
      <Maps:MapTileSource.DataSource> 
       <Maps:HttpMapTileDataSource UriFormatString="" /> 
      </Maps:MapTileSource.DataSource> 
     </Maps:MapTileSource> 
    </Maps:MapControl.TileSources> 
</Maps:MapControl> 

Düzenleme: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn632728.aspx de örnek kod çalıştı ve bu bariz görünüyor bu yüzden, ince çalıştığını MapTileSource kendisi kayıtsız değil. Ama bu tüm kod-kodlama ve veri bağlama kullanmaz, bu yüzden benim için çok fazla kullanılmaz.

Düzenleme 2: Ben hatayı görmezden ve telefon emülatörü uygulamayı dağıtmak çalışırsanız, bu bakış InitializeComponent() olsun:

proje platform hedefi nedir
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in HikePoint.exe but was not handled in user code 

WinRT information: Cannot deserialize XBF metadata type list as '%1' was not found in namespace '%0'. [Line: 0 Position: 0] 

Additional information: The text associated with this error code could not be found. 



Cannot deserialize XBF metadata type list as '%1' was not found in namespace '%0'. [Line: 0 Position: 0] 

If there is a handler for this exception, the program may be safely continued. 
+0

Bunun için bir çözüm bulamadınız mı? –

+0

Hayır, buna iki yönlü ihtiyaç duymadığım için bağlayıcı bir yardımcı kullandım. Eve gittiğimde istersen kodu gönderebilirim. –

+2

Bu hatayı nasıl atladığınıza sevindim. Bir CaptureElement kaynağına MediaCapture kaynamaya çalışırken aynı hatayı alıyorum. –

cevap

0

Sonunda vazgeçti ve sadece benim için bağlayıcı işlemek için bir davranış yaptı. TileSource senin ViewModel bir MapTileSource özelliği olan Böylece kullanmak

public class TileSourceBehavior : DependencyObject, IBehavior 
{ 
    public DependencyObject AssociatedObject { get; private set; } 

    public void Attach(Windows.UI.Xaml.DependencyObject associatedObject) 
    { 
     var mapControl = associatedObject as MapControl; 

     if (mapControl == null) 
      throw new ArgumentException("TileSourceBehavior can be attached only to MapControl"); 

     AssociatedObject = associatedObject; 
    } 

    public void Detach() { } 

    public static readonly DependencyProperty TileSourceProperty = 
     DependencyProperty.Register("TileSource", typeof(MapTileSource), typeof(TileSourceBehavior), new PropertyMetadata(null, OnTileSourcePropertyChanged)); 

    public MapTileSource TileSource 
    { 
     get { return GetValue(TileSourceProperty) as MapTileSource; } 
     set { SetValue(TileSourceProperty, value); } 
    } 

    private static void OnTileSourcePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) 
    { 
     var behavior = dependencyObject as TileSourceBehavior; 
     var mapControl = behavior.AssociatedObject as MapControl; 

     // remove the existing tile source 

     var existingTileSource = mapControl.TileSources.FirstOrDefault(t => t.Layer == MapTileLayer.BackgroundReplacement); 

     if (existingTileSource != null) 
      mapControl.TileSources.Remove(existingTileSource); 

     // add the tile source 

     behavior.TileSource.Layer = MapTileLayer.BackgroundReplacement; 
     mapControl.TileSources.Add(behavior.TileSource); 
    } 
} 

.

<Maps:MapControl> 
    <i:Interaction.Behaviors> 
    <behaviors:TileSourceBehavior TileSource="{Binding Path=TileSource}" /> 
    </i:Interaction.Behaviors> 
</Maps:MapControl> 
0

? Bunu x64 olarak değiştirmeyi deneyin.

Similar Question on SO

+0

Bu bir windows telefon uygulamasıdır; x64 geçerli bir oluşturma hedefi değil. –

+0

evet üzgünüm işten sonra deneyeceğim –

İlgili konular