Exemplo n.º 1
0
        private void TransformXamarinViewToUWPBitmap(Pin outerItem, ContentControl nativeItem)
        {
            if (outerItem?.Icon?.Type == BitmapDescriptorType.View && outerItem?.Icon?.View != null)
            {
                var iconView = outerItem.Icon.View;

                ViewToRendererConverter converter = new ViewToRendererConverter();
                var frameworkElement = converter.Convert(iconView, null, null, null) as FrameworkElement;

                frameworkElement.Height = iconView.HeightRequest;
                frameworkElement.Width  = iconView.WidthRequest;

                if (Icon != null)
                {
                    Root.Children.Remove(Icon);
                }
                Icon = frameworkElement;
                Root.Children.Add(Icon);
            }
        }
Exemplo n.º 2
0
        private void ShowToolTip()
        {
            var control = Control ?? Container;

            if (control is DependencyObject)
            {
                object toolTipContent;
                var    content = ToolTipEffect.GetContent(Element);

                if (content != null)
                {
                    var viewToRendererConverter = new ViewToRendererConverter();
                    var frameworkElement        = viewToRendererConverter.Convert(content, null, null, null);
                    toolTipContent = frameworkElement;
                }
                else
                {
                    toolTipContent = ToolTipEffect.GetText(Element);
                }
                toolTip = new ToolTip
                {
                    Background = XamarinColorToNative(ToolTipEffect.GetBackgroundColor(Element)),
                    Content    = toolTipContent ?? "n/a",
                    Placement  = GetPlacementMode()
                };

                var height = ToolTipEffect.GetHeight(Element);
                if (height > 0.0)
                {
                    toolTip.Height = height;
                }

                var width = ToolTipEffect.GetWidth(Element);
                if (width > 0.0)
                {
                    toolTip.Width = width;
                }

                ToolTipService.SetToolTip(control, toolTip);

                PlacementMode GetPlacementMode()
                {
                    switch (ToolTipEffect.GetPosition(Element))
                    {
                    case ToolTipPosition.Bottom:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom);

                    case ToolTipPosition.Top:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Top);

                    case ToolTipPosition.Left:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Left);

                    case ToolTipPosition.Right:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Right);

                    default:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Mouse);
                    }
                }
            }
        }