Skip to content

Commit

Permalink
Removing custom popup placement from combobox as it was not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Feb 20, 2015
1 parent 7b2c3fb commit c4f935a
Showing 1 changed file with 6 additions and 46 deletions.
52 changes: 6 additions & 46 deletions Fluent/Controls/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,16 +596,9 @@ public bool CanAddToQuickAccessToolBar
/// </summary>
public override void OnApplyTemplate()
{
if (popup != null) popup.CustomPopupPlacementCallback -= CustomPopupPlacementMethod;
popup = GetTemplateChild("PART_Popup") as Popup;
if (popup != null)
{
popup.Placement = PlacementMode.Custom;
popup.CustomPopupPlacementCallback += CustomPopupPlacementMethod;
}

this.popup = this.GetTemplateChild("PART_Popup") as Popup;

editableTextBox = GetTemplateChild("PART_EditableTextBox") as System.Windows.Controls.TextBox;
this.editableTextBox = this.GetTemplateChild("PART_EditableTextBox") as System.Windows.Controls.TextBox;

if (resizeVerticalThumb != null)
{
Expand Down Expand Up @@ -959,14 +952,14 @@ private void SetDragHeight(DragDeltaEventArgs e)
var delta = this.PointToScreen(new Point()).Y - dropDownBorder.ActualHeight - e.VerticalChange - monitorTop;
if (delta > 0)
{
scrollViewer.Height = Math.Max(0,
scrollViewer.Height = Math.Max(0,
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + e.VerticalChange),
MaxDropDownHeight));
}
else
{
delta = this.PointToScreen(new Point()).Y - dropDownBorder.ActualHeight - monitorTop;
scrollViewer.Height = Math.Max(0,
scrollViewer.Height = Math.Max(0,
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + delta),
MaxDropDownHeight));
}
Expand All @@ -978,53 +971,20 @@ private void SetDragHeight(DragDeltaEventArgs e)
var delta = monitorBottom - this.PointToScreen(new Point()).Y - ActualHeight - popupChild.ActualHeight - e.VerticalChange;
if (delta > 0)
{
scrollViewer.Height = Math.Max(0,
scrollViewer.Height = Math.Max(0,
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + e.VerticalChange),
MaxDropDownHeight));
}
else
{
delta = monitorBottom - this.PointToScreen(new Point()).Y - ActualHeight - popupChild.ActualHeight;
scrollViewer.Height = Math.Max(0,
scrollViewer.Height = Math.Max(0,
Math.Min(Math.Max(galleryPanel.GetItemSize().Height, scrollViewer.Height + delta),
MaxDropDownHeight));
}
}
}

/// <summary>
/// Implements custom placement for ribbon popup
/// </summary>
/// <param name="popupsize"></param>
/// <param name="targetsize"></param>
/// <param name="offset"></param>
/// <returns></returns>
CustomPopupPlacement[] CustomPopupPlacementMethod(Size popupsize, Size targetsize, Point offset)
{
if (popup != null)
{
Rect monitorRect = RibbonControl.GetControlMonitor(this);
Point pos = PointToScreen(new Point());

if (ShowPopupOnTop)
{
return new CustomPopupPlacement[]
{
new CustomPopupPlacement(new Point(0, -dropDownBorder.ActualHeight), PopupPrimaryAxis.Horizontal),
};
}
else
{

return new CustomPopupPlacement[]
{
new CustomPopupPlacement(new Point(0, ActualHeight), PopupPrimaryAxis.Horizontal),
};
}
}
return null;
}

#endregion
}
}

0 comments on commit c4f935a

Please sign in to comment.