tag:blogger.com,1999:blog-5295746446529817470.post8017519964283843716..comments2023-05-09T16:29:24.130+02:00Comments on Dotnet by Example: A WinRT behavior to mimic EventToCommand (take 2)Joost van Schaikhttp://www.blogger.com/profile/02182444268071162776noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-5295746446529817470.post-7684707611805639642013-03-25T11:09:19.054+01:002013-03-25T11:09:19.054+01:00@Alex Schlögl, Try putting your AppBar inside the ...@Alex Schlögl, Try putting your AppBar inside the main grid, or make your appbar inside a usercontrol<br />here is a solution.<br /><br />http://stackoverflow.com/questions/14320377/mvvm-windows-8-appbar-mvvm-event/14980554#14980554DrZoidberghttps://www.blogger.com/profile/11294251307947427010noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-91368566788166506032013-03-25T09:57:19.364+01:002013-03-25T09:57:19.364+01:00@DrZoidberg I got the same issue. Did someone alre...@DrZoidberg I got the same issue. Did someone already got a solution for that? I don't want to use the "normal" events in the View.cs to handle when my app bar shows or hides.<br /><br />Thx,<br />AlexAnonymoushttps://www.blogger.com/profile/13230288820407402793noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-90827233465701956982013-03-15T13:06:08.313+01:002013-03-15T13:06:08.313+01:00@Jürgen,
Do you have a repro solution? I can try ...@Jürgen,<br /><br />Do you have a repro solution? I can try to guess what you are doing wrong, but looking at your actual code will probably more usefulJoost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-15889326958746065952013-03-14T17:14:55.881+01:002013-03-14T17:14:55.881+01:00@Joost:
the Loaded event is a RoutedEvent:
public...@Joost: <br />the Loaded event is a RoutedEvent:<br />public event RoutedEventHandler Loaded;<br /><br />The event itself is not the problem:<br />I copied the sources of the EventToBoundCommandBehavior to debug and see what happened with the Loaded event.<br />The problem is in this special case is the bound command is always null. I don't know why.<br />It seems the viewmodel is not bound to the page if the Loaded event is fired. I don't know why because the DataContext is bound directly in the page via a viewmodel locator:<br />DataContext="{Binding Main, Source={StaticResource Locator}}"<br /><br />Chears,<br />Juergen<br />Jürgen Gutschhttps://www.blogger.com/profile/07351355667871096846noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-45883552213355869892013-02-24T13:18:55.111+01:002013-02-24T13:18:55.111+01:00@DrZoidberg to bind a command to a button you don&...@DrZoidberg to bind a command to a button you don't need this behavior at all - just bind directly to the button's "Command" property. If you try to subscribe to another event, kindly provide a repro sample that I can debug and I will have a look at it.Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-27494896793965310112013-02-20T13:50:35.037+01:002013-02-20T13:50:35.037+01:00Hi, your methods works perfectly to fire a command...Hi, your methods works perfectly to fire a command behind a button in a normal view, but when i put a button in the AppBar and create command, the whole application crashes when i open the AppBar, before even clicking on a button.<br />I'm using MVVM light and the ICommand.<br /><br />thxDrZoidberghttps://www.blogger.com/profile/11294251307947427010noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-2638284075324471182013-02-12T08:36:26.330+01:002013-02-12T08:36:26.330+01:00Hi again, I solved my problem. Solution was a LOT ...Hi again, I solved my problem. Solution was a LOT simpler than I would've thought.<br /><br />For some reason I had presumed the only way to get my data is by using the refresh command I'd created before. But all I had to do is call the method doing all the work for the command, in the ViewModel constructor and done.<br /><br />So in this case I didn't need event to command functionality at all. Just thought I'd post this in case someone else is also overthinking MVVM when they're getting started.<br /><br />ThanksAnonymoushttps://www.blogger.com/profile/02286621040952388929noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-48676699141668872812013-02-11T08:50:02.132+01:002013-02-11T08:50:02.132+01:00@Simo, the behavior only attaches to events of typ...@Simo, the behavior only attaches to events of type RoutedEvent. It may just be that Loaded is not a RoutedEvent. I need to check that. Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-92001236431608692922013-02-09T22:16:07.581+01:002013-02-09T22:16:07.581+01:00Hi,
First of all: nice work!
I'm fairly new ...Hi,<br /><br />First of all: nice work!<br /><br />I'm fairly new to WinRT & MVVM, so I hope this won't sound too dumb.<br /><br />Basically, I want to load some data on page load. Since I've already got a command (RelayCommand) that does the work, I thought it'd be great if I could just fire that command on Loaded event of the page.<br /><br />So, I wrote:<br /><br /> <br /> <br /><br />Other events, such as Tapped, GotFocus worked, but not Loaded. What may be the problem?<br /><br />Thanks!<br />SimAnonymoushttps://www.blogger.com/profile/02286621040952388929noreply@blogger.com