just.a.hriday
just.a.hriday
CC#
Created by just.a.hriday on 5/18/2024 in #help
(WinUI 3) Visual State Manager throwing System.Runtime.InteropServices.COMException
I use the VisualStateMangaer.GoToState() method twice, with the same parameters. Strangely, it only works in one of the situations and throws an exception in the other. What am I missing here?
c#
private void DialogLoaded (object sender, RoutedEventArgs e)
{
VisualStateManager.GoToState(this, InternetConnected() ? "IsbnEnabled" : "IsbnDisabled", false);
// This works perfectly fine.

NetworkInformation.NetworkStatusChanged += delegate
{
bool connected = InternetConnected();

VisualStateManager.GoToState(this, connected ? "IsbnEnabled" : "IsbnDisabled", false);
// This one throws a System.Runtime.InteropServices.COMException with no message.
};
}
c#
private void DialogLoaded (object sender, RoutedEventArgs e)
{
VisualStateManager.GoToState(this, InternetConnected() ? "IsbnEnabled" : "IsbnDisabled", false);
// This works perfectly fine.

NetworkInformation.NetworkStatusChanged += delegate
{
bool connected = InternetConnected();

VisualStateManager.GoToState(this, connected ? "IsbnEnabled" : "IsbnDisabled", false);
// This one throws a System.Runtime.InteropServices.COMException with no message.
};
}
1 replies