diff --git a/dotnet-desktop-guide/framework/wpf/controls/popup-overview.md b/dotnet-desktop-guide/framework/wpf/controls/popup-overview.md index cec7771..a925035 100644 --- a/dotnet-desktop-guide/framework/wpf/controls/popup-overview.md +++ b/dotnet-desktop-guide/framework/wpf/controls/popup-overview.md @@ -1,7 +1,7 @@ --- title: "Popup Overview" description: Learn about the Windows Presentation Foundation Popup control, which provides a way to display content in a window that floats over the current application. -ms.date: "03/30/2017" +ms.date: "07/14/2021" helpviewer_keywords: - "controls [WPF], Popup" - "Popup control [WPF], about Popup control" @@ -19,12 +19,11 @@ The control provides a way to di ## Creating a Popup - The following example shows how to define a control that is the child element of a control. Because a can have only one child element, this example places the text for the and the controls in a . The content of the appears in a control, which displays its text in a separate window that floats over the application window near the related control. - - [!code-xaml[PopupSimple#1](~/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml#1)] - - [!code-xaml[PopupSimple#CreatePopupCodeXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml#createpopupcodexaml)] + +The following example shows how to define a control that is the child element of a control. Because a `ToggleButton` can have only one child element, this example places the text for the `ToggleButton` and the `Popup` controls in a . The content of the `Popup` is displayed in a separate window that floats over the application window near the related `ToggleButton` control. +:::code language="xaml" source="snippets/popup-overview/csharp/Window1.xaml" id="ToggleButtonCodeless"::: + ## Controls That Implement a Popup You can build controls into other controls. The following controls implement the control for specific uses: diff --git a/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/CSharpExample.csproj b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/CSharpExample.csproj new file mode 100644 index 0000000..499d8ad --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/CSharpExample.csproj @@ -0,0 +1,10 @@ + + + + WinExe + net5.0-windows + true + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/Window1.xaml b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/Window1.xaml new file mode 100644 index 0000000..ae34b78 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/Window1.xaml @@ -0,0 +1,64 @@ + + + + + This sample shows examples of a Popup controls + that are the logical children of a Buttons. Each Popup + window is positioned with respect to a Button. However, + because the Popup content is contained in its own window, + the Popup is not a visual child of the Button. + + + + + Type the content you want to appear in the Popup in the text + box below and then click the button to display the Popup + + + Type your Popup text here + + + + + + + + + + + + + Popup Text + + + + + + + + + Click the button to create a Popup by using code + + + + + + + + + + diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml.cs b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/Window1.xaml.cs similarity index 75% rename from dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml.cs rename to dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/Window1.xaml.cs index bd01605..595c969 100644 --- a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml.cs +++ b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/Window1.xaml.cs @@ -36,20 +36,20 @@ namespace Popup_Properties_Sample } // - // + // private void CreatePopup(object sender, RoutedEventArgs e) { - // Popup codePopup = new Popup(); - TextBlock popupText = new TextBlock(); - popupText.Text = "Popup Text"; - popupText.Background = Brushes.LightBlue; - popupText.Foreground = Brushes.Blue; + TextBlock popupText = new() + { + Text = "Popup Text", + Background = Brushes.LightBlue, + Foreground = Brushes.Blue + }; codePopup.Child = popupText; - // - aStackPanel.Children.Add(codePopup); + ButtonContentContainer.Children.Add(codePopup); codePopup.IsOpen = true; } - // + // } -} \ No newline at end of file +} diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/app.xaml b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/app.xaml similarity index 100% rename from dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/app.xaml rename to dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/app.xaml diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/app.xaml.cs b/dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/app.xaml.cs similarity index 100% rename from dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/app.xaml.cs rename to dotnet-desktop-guide/framework/wpf/controls/snippets/popup-overview/csharp/app.xaml.cs diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/PopupPropertiesSample.csproj b/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/PopupPropertiesSample.csproj deleted file mode 100644 index 051cb0c..0000000 --- a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/PopupPropertiesSample.csproj +++ /dev/null @@ -1,58 +0,0 @@ - - - Debug - AnyCPU - {D3D69C55-A09F-473C-99B8-876826A68796} - Popup_Properties_Sample - Popup Properties Sample - 4 - winexe - 1.0.0.* - - 10.0.20821 - 2.0 - v4.0 - Client - - - true - full - false - .\bin\Debug\ - DEBUG;TRACE - - - false - true - .\bin\Release\ - TRACE - - - - - - - - - - 4.0 - - - - - - - - - - - app.xaml - Code - - - Window1.xaml - Code - - - - \ No newline at end of file diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml b/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml deleted file mode 100644 index be71214..0000000 --- a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/Window1.xaml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - This sample shows examples of a Popup controls - that are the logical children of a Buttons. Each Popup - window is positioned with respect to a Button. However, - because the Popup content is contained in its own window, - the Popup is not a visual child of the Button. - - - - - Type the content you want to appear in the Popup in the text - box below and then click the button to display the Popup - - - Type your Popup text here - - - - - - - Click the button to create a Popup by using code - - - - - - - - - - diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/sampleid.txt b/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/sampleid.txt deleted file mode 100644 index f72e415..0000000 --- a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/PopupSimple/CSharp/sampleid.txt +++ /dev/null @@ -1 +0,0 @@ -wcsamp_components_popupsimple \ No newline at end of file