0

I have a View and in this view I have a behaviour:

<Grid x:Name="main" Style="{StaticResource GridMain}" 
 behaviors:KeyboardFocusBehavior.On="{Binding ElementName=somecontrol}">
</Grid>

In my viewmodel I have a boolean property named SuccesfullyLoggedIn.

I am trying to run the behaviour only at the moment SuccesfullyLoggedIn is true.

How can achieve this? Currently when the view is loaded the behaviour is running. I want this to be ran only when the SuccesfullyLoggedIn is true and not on the load

Il Vic
  • 5,576
  • 4
  • 26
  • 37
user1702369
  • 1,089
  • 2
  • 13
  • 31
  • What does your behavior do? How it should be conditioned by `SuccesfullyLoggedIn`? It `SuccesfullyLoggedIn` the trigger for your logic or it is unleashed by the `KeyboardFocusBehavior`'s binding? – Il Vic Jan 04 '18 at 13:45
  • Check if SuccesfullyLoggedIn is true in your behaviour? – mm8 Jan 04 '18 at 14:16
  • I have a mainview that puts focus on a Button (The Behaviour does this.) The problem is that this only happens when the mainview is loaded. But now over the mainview comes a Login usercontrol that sets focus on the username which means the focus gets transferred from the mainview to the LoginView. Once this loginView is closed(Successfully LoggedIn) I return back to my MainView and the focus needs to be set to my button again, but it does not. This happens because the behaviour does not trigger to set the focus again. Therefore I want to trigger/rerun the behaviour once LogIn was successfull. – user1702369 Jan 05 '18 at 09:59

0 Answers0