--- title: "How to: Specify a Custom Popup Position" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "Popup control [WPF], specifying custom position" ms.assetid: 28c24f39-d3aa-4ee2-b950-384b4a5dab92 --- # How to: Specify a Custom Popup Position This example shows how to specify a custom position for a control when the property is set to . ## Example When the property is set to , the calls a defined instance of the delegate. This delegate returns a set of possible points that are relative to the top-left corner of the target area and the top-left corner of the . The placement occurs at the point that provides the best visibility. The following example shows how to define the position of a by setting the property to . It also shows how to create and assign a delegate in order to position the . The callback delegate returns two objects. If the is hidden by a screen edge at the first position, the is placed at the second position. [!code-xaml[PopupCustomPlacement#CustomPlacement](~/samples/snippets/csharp/VS_Snippets_Wpf/PopupCustomPlacement/CSharp/Window1.xaml#customplacement)] [!code-csharp[PopupCustomPlacement#DelegateInstance](~/samples/snippets/csharp/VS_Snippets_Wpf/PopupCustomPlacement/CSharp/Window1.xaml.cs#delegateinstance)] [!code-vb[PopupCustomPlacement#DelegateInstance](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PopupCustomPlacement/visualbasic/window1.xaml.vb#delegateinstance)] [!code-csharp[PopupCustomPlacement#DelegateDefinition](~/samples/snippets/csharp/VS_Snippets_Wpf/PopupCustomPlacement/CSharp/Window1.xaml.cs#delegatedefinition)] [!code-vb[PopupCustomPlacement#DelegateDefinition](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PopupCustomPlacement/visualbasic/window1.xaml.vb#delegatedefinition)] For the complete sample, see [Popup Placement Sample](https://github.com/dotnet/docs-desktop/tree/main/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupPositionSnippet/CS). ## See also - - [Popup overview](popup-overview.md) - [How-to articles](popup-how-to-topics.md)