作成日: 2017/03/05, 更新日: 2017/03/05
Popup
- popup は、ポップアップウィンドウを表示するためのコントロールです。 とりあえずどういう風に動くのか見てみましょう。 以下サンプルです。「PopupWindow1」という画面で作成していますが、「MainWindow」に書いても構いません。

スポンサーリンク
<Window x:Class="PopupWindow1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:z04_NormalControls" mc:Ignorable="d" Title="PopupWindow1" Height="300" Width="300"> <Grid> <StackPanel Margin="50" Background="AliceBlue"> <Button Name="button1" Content="button1" Width="150" Height="150" /> <Popup IsOpen="True" PlacementTarget="{Binding ElementName=button1}" Placement="Bottom"> <TextBlock FontSize="14" Background="LightGreen" Text="Placement=Bottom" /> </Popup> <Popup IsOpen="True" PlacementTarget="{Binding ElementName=button1}" Placement="Top"> <TextBlock FontSize="14" Background="LightGreen" Text="Placement=Top" /> </Popup> <Popup IsOpen="True" PlacementTarget="{Binding ElementName=button1}" Placement="Left"> <TextBlock FontSize="14" Background="LightGreen" Text="Placement=Left" /> </Popup> <Popup IsOpen="True" PlacementTarget="{Binding ElementName=button1}" Placement="Right"> <TextBlock FontSize="14" Background="LightGreen" Text="Placement=Right" /> </Popup> <Popup IsOpen="False" PlacementTarget="{Binding ElementName=button1}" Placement="Center"> <TextBlock FontSize="14" Background="LightGreen" Text="Placement=Center" /> </Popup> </StackPanel> </Grid> </Window>
<Window x:Class="PopupWindow2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:z04_NormalControls" mc:Ignorable="d" Title="PopupWindow2" Height="300" Width="300"> <Grid> <StackPanel Margin="50" Background="AliceBlue"> <Popup Placement="Bottom" IsOpen="True"> <StackPanel> <TextBlock Text="popup1" Background="White" /> <Button Content="popup2" /> </StackPanel> </Popup> </StackPanel> </Grid> </Window>
スポンサーリンク
<Window x:Class="PopupWindow3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:z04_NormalControls" mc:Ignorable="d" Title="PopupWindow3" Height="300" Width="300"> <Grid> <StackPanel Margin="50" Background="AliceBlue"> <Popup Placement="Bottom" IsOpen="True"> <StackPanel> <TextBlock Text="popup1" Background="White" /> <Button Content="popup2" /> </StackPanel> </Popup> <Popup Placement="Bottom" IsOpen="True" HorizontalOffset="50" VerticalOffset="20"> <StackPanel> <TextBlock Text="popup3" Background="White" /> <Button Content="popup4" /> </StackPanel> </Popup> </StackPanel> </Grid> </Window>
<Window x:Class="PopupWindow4" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:z04_NormalControls" mc:Ignorable="d" Title="PopupWindow4" Height="300" Width="300"> <Grid> <StackPanel Margin="50" Background="AliceBlue"> <Popup Placement="Bottom" IsOpen="True"> <StackPanel> <TextBlock Text="popup1" Background="White" /> <Button Content="popup2" /> </StackPanel> </Popup> <Popup Placement="Bottom" IsOpen="True" HorizontalOffset="-50" VerticalOffset="-20"> <StackPanel> <TextBlock Text="popup3" Background="White" /> <Button Content="popup4" /> </StackPanel> </Popup> </StackPanel> </Grid> </Window>
-
前(Label)に戻る 目次に戻る 次(ProgressBar)に進む
スポンサーリンク