Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

New Post: Vb.net Yield

$
0
0
I've been playing around with Jens Petterson's login example. I'm trying to see if I can convert the example to a VB.Net WPF project. I've done some reading on using the Yield statement in an Iterator function in VB and so tried to translate the example. I'm wondering if this would be the correct translation. The code runs but for some reason instead of the LoginResultsView I get a message saying it couldn't find view for LoginResultsViewModel.
     Public Iterator Function Login() As IEnumerable(Of IResult)
        ' do some login logic...
        Dim success As Boolean = False

        If UserName = "admin" AndAlso Password = "admin" Then
            success = True
        End If

        If success Then 
            Yield Show.Child(Of LoginResultViewModel)().[In](Of IShell)().Configured(Function(c) InlineAssignHelper(c.ResultMessage, "Successfully logged in!"))
        Else
            Yield Show.Child(Of LoginResultViewModel)().[In](Of IShell)().Configured(Function(c) InlineAssignHelper(c.ResultMessage, "You failed to log in!"))
        End If
    End Function
public IEnumerable<IResult> Login()
        {
            // do some login logic...
            bool success = false;

            if (UserName == "admin" && Password == "admin")
                success = true;

            if (success)
            {
                yield return
                    Show.Child<LoginResultViewModel>().In<IShell>().Configured(c => c.ResultMessage = "Successfully logged in!");
            }
            else
            {
                yield return
                    Show.Child<LoginResultViewModel>().In<IShell>().Configured(c => c.ResultMessage = "You failed to log in!");
            }
        }

Viewing all articles
Browse latest Browse all 1760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>