コード例 #1
0
        /// <summary>
        /// Will handle the item template change
        /// </summary>
        /// <param name="d">DependencyObject that triggers the event.</param>
        /// <param name="e">Event args</param>
        private static void OnItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MapItemsControl mapsItemControl;
            DataTemplate    dataTemplate;

            mapsItemControl = (MapItemsControl)d;
            dataTemplate    = (DataTemplate)e.NewValue;

            mapsItemControl.ItemsChangeManager.ItemTemplate = dataTemplate;

            foreach (MapOverlay mapOverlay in mapsItemControl.MapLayer)
            {
                // New template, so there will be a new ui element created
                MapChild.ClearMapOverlayBindings(mapOverlay);

                MapOverlayItem mapOverlayPresenterHelper = (MapOverlayItem)mapOverlay.Content;
                mapOverlayPresenterHelper.ContentTemplate = dataTemplate;
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a MapOverlay with the specified content and content template.
        /// It will have special setup so that later the dependency properties from MapOverlay
        /// and the attached properties from the target UI can be in a binding.
        /// </summary>
        /// <param name="content">Content of the MapOverlay</param>
        /// <param name="contentTemplate">Template to be used in the MapOverlay</param>
        /// <returns>The MapOverlay that was created</returns>
        internal static MapOverlay CreateMapOverlay(object content, DataTemplate contentTemplate)
        {
            MapOverlay     mapOverlay;
            MapOverlayItem presenterHelper;

            mapOverlay      = new MapOverlay();
            presenterHelper = new MapOverlayItem(content, contentTemplate, mapOverlay);

            // For insertion and removal purposes, we will have a diferentiation between
            // map overlays that are created by this toolkit and when they are not.
            // This will help to determine, when they are removed, to which
            // we will need to to speacial cleaning
            mapOverlay.SetValue(MapChild.ToolkitCreatedProperty, true);
            mapOverlay.Content = presenterHelper;

            // The dependency properties from MapOverlay, will be binded
            // until the content finally has a UI.
            // At that point, we will try to get the actual ui
            // and bind the attached properties from the ui to the
            // dependency properties of the map overlay.
            return(mapOverlay);
        }
コード例 #3
0
ファイル: MapChild.cs プロジェクト: JanJoris/VikingApp
        /// <summary>
        /// Creates a MapOverlay with the specified content and content template.
        /// It will have special setup so that later the dependency properties from MapOverlay
        /// and the attached properties from the target UI can be in a binding.
        /// </summary>
        /// <param name="content">Content of the MapOverlay</param>
        /// <param name="contentTemplate">Template to be used in the MapOverlay</param>
        /// <returns>The MapOverlay that was created</returns>
        internal static MapOverlay CreateMapOverlay(object content, DataTemplate contentTemplate)
        {
            MapOverlay mapOverlay;
            MapOverlayItem presenterHelper;

            mapOverlay = new MapOverlay();
            presenterHelper = new MapOverlayItem(content, contentTemplate, mapOverlay);

            // For insertion and removal purposes, we will have a diferentiation between
            // map overlays that are created by this toolkit and when they are not.
            // This will help to determine, when they are removed, to which
            // we will need to to speacial cleaning
            mapOverlay.SetValue(MapChild.ToolkitCreatedProperty, true);
            mapOverlay.Content = presenterHelper;

            // The dependency properties from MapOverlay, will be binded
            // until the content finally has a UI.
            // At that point, we will try to get the actual ui 
            // and bind the attached properties from the ui to the 
            // dependency properties of the map overlay.
            return mapOverlay;
        }