Exemple #1
0
        public void GemButtonClick(Item gem, Control relativeTo, Action <Item> callback)
        {
            gemCallback = null;
            ComparisonGemList.SelectedItem = gem;

            GeneralTransform gt     = relativeTo.TransformToVisual(LayoutRoot);
            Point            offset = gt.Transform(new Point(relativeTo.ActualWidth + 4, 0));

            GemPopup.VerticalOffset   = offset.Y;
            GemPopup.HorizontalOffset = offset.X;

            ComparisonGemList.Measure(App.Current.RootVisual.RenderSize);

            // this doesn't work in WPF
            // The specified Visual and this Visual do not share a common ancestor, so there is no valid transformation between the two Visuals.
#if SILVERLIGHT
            GeneralTransform transform = relativeTo.TransformToVisual(App.Current.RootVisual);
            double           distBetweenBottomOfPopupAndBottomOfWindow =
                App.Current.RootVisual.DesiredSize.Height -
                transform.Transform(new Point(0, ComparisonGemList.DesiredSize.Height)).Y;
            if (distBetweenBottomOfPopupAndBottomOfWindow < 0)
            {
                GemPopup.VerticalOffset += distBetweenBottomOfPopupAndBottomOfWindow;
            }
#else
            // use PlacementTarget for WPF
            GemPopup.PlacementTarget = LayoutRoot;
#endif

            ComparisonGemList.IsShown = true;
            GemPopup.IsOpen           = true;
            ComparisonGemList.Focus();
            gemCallback = callback;
        }
Exemple #2
0
        public void GemButtonClick(Item gem, Control relativeTo, Action <Item> callback)
        {
            gemCallback = null;
            ComparisonGemList.SelectedItem = gem;

            GeneralTransform gt     = relativeTo.TransformToVisual(LayoutRoot);
            Point            offset = gt.Transform(new Point(relativeTo.ActualWidth + 4, 0));

            GemPopup.VerticalOffset   = offset.Y;
            GemPopup.HorizontalOffset = offset.X;

            ComparisonGemList.Measure(App.Current.RootVisual.RenderSize);

            GeneralTransform transform = relativeTo.TransformToVisual(App.Current.RootVisual);
            double           distBetweenBottomOfPopupAndBottomOfWindow =
                App.Current.RootVisual.DesiredSize.Height -
                transform.Transform(new Point(0, ComparisonGemList.DesiredSize.Height)).Y;

            if (distBetweenBottomOfPopupAndBottomOfWindow < 0)
            {
                GemPopup.VerticalOffset += distBetweenBottomOfPopupAndBottomOfWindow;
            }

            ComparisonGemList.IsShown = true;
            GemPopup.IsOpen           = true;
            ComparisonGemList.Focus();
            gemCallback = callback;
        }