简单使用例子

代码

  1. <Grid>
  2. <Button
  3. x:Name="btnShowPopup"
  4. Width="200"
  5. Height="24"
  6. Click="BtnShowPopup_OnClick">
  7. Show Popup
  8. </Button>
  9. <Popup
  10. x:Name="pop1"
  11. Width="120"
  12. Height="120"
  13. AllowsTransparency="True"
  14. IsOpen="False"
  15. Placement="Bottom"
  16. PlacementTarget="{Binding ElementName=btnShowPopup}"
  17. PopupAnimation="Slide"
  18. StaysOpen="False">
  19. <StackPanel Background="Gray">
  20. <Button Content="button1" />
  21. <Button Content="button2" />
  22. <Button Content="button3" />
  23. </StackPanel>
  24. </Popup>
  25. </Grid>
  1. private void BtnShowPopup_OnClick(object sender, RoutedEventArgs e)
  2. {
  3. pop1.IsOpen = true;
  4. }

效果

popup sample.gif