gpt4 book ai didi

c# - 在 xaml 中定义时如何避免创建多个弹出窗口?

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:46 24 4
gpt4 key购买 nike

我想在事件页面中显示弹出窗口。我在页面定义中添加了一个弹出窗口。它第一次工作正常。但由于 Popup 不是 visual-tree 的一部分,因此下次访问该页面时会再次创建弹出窗口。我怎样才能避免这种情况?我知道的唯一选择是在代码隐藏中编写一个静态弹出窗口。但是有什么办法可以在 xaml 中做到这一点吗? (或者可能在虚拟机中)

这是我在 XAML 中的代码。

<Popup Grid.Row="2" x:Name="popup" IsOpen="{Binding VenueListOpen}">
<ScrollViewer Height="600" Margin="0,0,0,20" Background="#55000000">
<StackPanel Width="{Binding DeviceWidth}">
<ItemsControl ItemsSource="{Binding EventsList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="20,0" Background="{Binding BindsDirectlyToSource=True, Converter={StaticResource EventRowBackgroundConverter}}">
<TextBlock Margin="20,5" FontSize="30" Text="Metlife stadium" TextWrapping="Wrap"/>
<TextBlock Margin="20,5" Foreground="SkyBlue" Text="www.metlifestadium.com" TextWrapping="Wrap"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
</Popup>

最佳答案

在进入页面时将其Visible属性设置为false或true怎么样?

关于c# - 在 xaml 中定义时如何避免创建多个弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18655564/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com