showing popup from viewmodel #17522
-
Hi I set my variable in the viewmodel using ObservableProperty
I bind
during my code execution I set it to
But the the popup does not show If I set the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @ashah7, how do you update the public ICommand Command { get; set; }
[ObservableProperty]
private Boolean openpopupformessages = false;
public MainViewModel()
{
Command = new RelayCommand(ExecuteCommand);
}
private void ExecuteCommand()
{
Openpopupformessages = !Openpopupformessages; //you can set it to just true, it will only open the popup
} MainPage.xaml: <Button Command="{Binding Command}" Grid.Row="1" Content="open" />
<Popup x:Name="StandardPopupforMessages"
IsOpen="{Binding Openpopupformessages}">
<Border BorderBrush="{StaticResource ApplicationForegroundThemeBrush}"
Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
BorderThickness="2"
Width="480"
Height="320">
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock><Run Text="test" /></TextBlock>
<Button Content="Close"
CornerRadius="0"
Background="Gray"
Width="120"
MinHeight="25"
HorizontalAlignment="Center"
Margin="0,15,0,0"
Command="{Binding Command}" />
</StackPanel>
</Border>
</Popup> And it seems to be showing and closing well: Screen.Recording.2024-07-15.082515.mp4 |
Beta Was this translation helpful? Give feedback.
Ah, I see! Thank you for specifying the details in your scenario. For this, I think you will need to enqueue the request with a dispatcher, as this might be running on a different thread. As an example, you can do something like this:
Please let me know if this helps for your scenario as I didn't test it on my side. We can investigate further if not.