0

I have a little problem with my modern UI application. I can'T figure out how can I run a simple Button Commmand Binding in Links Group, because i don't want show a new page . I only want run my Logout code in code behind with Command Binding.

Example what I want

Ofcourse,I know this is just an idea that does not work. I only search a possible solution.

can someone advise something?

Birek
  • 85
  • 6

1 Answers1

0

Your command needs to be a property and the DataContext of where you are trying to use it needs to be set to where your property is stored (typically in a view model). If you are using the code behind you can set the data context to the window or user control (whichever it is) and have access to the property for binding purposes; however, this is a bad practice and you will benefit more from using a view model.

So in short, create a view model with your command as a property. Set the DataContext to the view model and then bind to the property.

HoboCannibaL
  • 171
  • 7
  • Yes, i know that.Every Command property works fine. But modern UI Link does not allow Command Binding. This is my problem. So i search a alternative way. – Birek Jun 30 '16 at 12:59
  • It can't be extended and given support for it? – HoboCannibaL Jun 30 '16 at 13:03
  • Modern UI have lot of examples But don't answer every questions. – Birek Jun 30 '16 at 13:05
  • The Command property in your example does not exist on the mui:Link element. You would need to be able to derive from it and then add the dependency property for Command and then write the functionality to execute the command. You should be able to do what you want if you can inherit the control and add the parts that you need to extend. – HoboCannibaL Jun 30 '16 at 13:21
  • I accept this question. I make a new Page and new viewmodel , when i click on Logout Title. i run the logout command in viewmodel constructor or new page but old viewmodel and when i intial the new page i send a message to old viewmodel, than close the window. – Birek Jun 30 '16 at 13:45