I'm making a Sketchflow WP7 application which is working fine, except Navigation is sometimes buggy. Sometimes when I go to a screen and try and click it doesn't work, some times it does. I'm using the MouseLeftButtonDown Event to trigger it. After it 'freezes' I can no longer navigate via the map either, though before it freezes I can. I'm not sure if any errors are thrown because I'm not aware of a real time silverlight console. Sketchflow doesn't have a 'Debug Project' option only a 'Run Project' one.
It's very unpredictable, sometimes it works, sometimes it doesn't (though some links are more unreliable than others). Sometimes it gets stuck in different screens. I've tested this across browsers and computers and while sometimes a new browser occasionally has a better success rate, something always gets stuck.
I'm afraid I'm probably leaving out some details so feel free to ask for them. I'm not really very familiar with Silverlight and Sketchflow, I'm just working on a prototype so it seems like I shouldn't have to deal with any code based issues...
Thanks!
You might want to look for a Click Event rather than MouseButtonDown as that could be anything, it doesnt mean MouseButton Down, MouseButton Up, which resembles a click. this is just the same as if you use your finger to touch the screen, this would also trigger the MouseButton Down Eventhandler
so if I was you try and use the Click eventhandler for your navigation.
You can open the same project in VS (including the free express editions) and run it in the debugger from there to see if an exception is being thrown. That might help narrow down the problem.
Related
I've created a WPF touchscreen application at work.
When I use a mouse, it behaves as you would expect. However, when using the touchscreen it doesn't behave as it should. It will regularly lag on a PreviewMouseDown touch event, and sometimes won't actually respond at all. Other times it works fine.
Does anybody know what could cause this behaviour, and what can I do to resolve it?
Many thanks
In researching the issue for someone over at EE, I ran across this post. Essentially, the PreviewTouchDown event does not occur until a finger touches the screen and moves. The answering post author goes on to say
To cause the PreviewTouchDown event to occur as soon as a finger touches the screen, set the Stylus.IsPressAndHoldEnabled attached property to false for this element.
This solution was posted in early 2014 and hasn't been rebutted, so it should work.
I'm making an application to dynamically add user controls on a Canvas and drag them around.
First I made a window with a canvas to drag them in and everything worked fine.
Then i made a user control with the code from the window. I added the control to a new window and everything still was working fine.
Now I try to add my control to the main application and the performance is very slow. The controls still follow the mouse but very slow. The application does have several other user controls. Where does this huge performance hit come from and how can I avoid it?
The cpu only uses 50% and when it was working good it went to 100%.
Thank you for you're help
David
EDIT:
I resolved the problem.
By moving the user-controls there was an error in the image url wich prevented the application to run smoothly.
By changing the url's everything went back to normal.
Ive used JoshSmiths DragCanvas for this kind of thing. It work great with no lag.
JoshSmiths DragCanvas # CodeProject
I resolved the problem. By moving the user-controls there was an error in the image url which prevented the application to run smoothly.
By changing the url's everything went back to normal.
Make sure to check you're url's if you're having sudden performance issues.
I have a certain UI element, which when clicked should navigate to another URL.
I tried handling the mouse down event and execute something like this:
System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("http://google.com"), "_blank");
However, this gets blocked by the browser (I tried both Chrome and Firefox) unless I disable the popup blocker.
I did some research and it seems that the browser blocks navigations that don't occur as a result of user interaction and as far as the browser is concerned this navigation is initiated by a plugin (Silverlight), not a user.
OK, makes sense. But then I tried using a HyperlinkButton instead and it was NOT blocked.
I wonder why these two approaches get different treatment from the browser. Any idea?
I actually worked around the problem by wrapping the navigation triggering UI with a HyperLinkButton, but I'm still very curious...
I'm going to pull a fancy corporate quote and say "It is a feature, not a bug."
The Silverlight team is obviously worried about Security. They don't want crazy haxorz like you and I to do crazy things with our apps--you know, like popping up a bunch of browser windows all routing people to Zombo.com. Just imagine the choir! Zombo!
Summarized from their documentation: They want us to only use the HyperlinkButton to go outside of their application. In fact, they went the extra step, and depending on our settings, they will even throw a SecurityException for us if we navigate to an outside page--Even from a HyperlinkButton. How nice.
The real question: Why the Hyperlink Button and not something else?
Only one "thing" can navigate. this take saves time for Microsoft while testing Silverlight. This one thing can navigate to both internal XAML pages and external web pages--Might as well be consistent and have only one way to do navigation.
It is a UIElement. It's code behind likes to run in the primary visual thread. It can promise the browser that a Visual Element wants to go somewhere. Microsoft can also put its limiting logic in a control that requires a mouse-click/keyboard-input event tree.
All in all, it makes sense to start simple by making a control do the work.
Fun stuff! Hope this helps you.
In my cocoa application I have a WebView. If I set that WebView to display a web page that contains Silverlight, the mouse move event never fires in that Silverlight application (with the exception of if I hold down the mouse button while moving). Everything else seems to work fine (clicking, interacting with objects) except for mouse move. Anyone have any ideas what is causing this and how to fix it?
Found out what the problem was. When Silverlight is embedded in a WebView (from WebKit) appears to have different concerns regarding threading (Firefox on OS X does not exhibit this problem). The solution was making sure that anything that touched a UI Object was in a control.Dispatcher.BeginInvoke (specifically in my case I was changing the text on a TextBlock in response to a MouseMove and that was causing the whole MouseMove to error out).
Hope this helps someone.
I've got an issue with a WPF application that I'm writing. The app needs to be able to keep focus at all times. The computer it's running on is a highly specialized machine with the only purpose of running this application.
There is no keyboard connected to the machine (it has a touch screen), so the only thing that can steal focus is windows own "needy windows", such as windows update etc.
How can I make it so that my app retains focus at all times? Is it possible to make the entire app modal?
EDIT:
Thank you both for your answers. I think I'll end up using Topsmost for now, but I'll definitely check out the source of babysmash as that application works exactly the way I want mine to, in regards to the way it handles focus.
Look at the source of BabySmash. It is specifically designed to keep focus even under quite bizar circumstances. (It is a program designed to run at full screen and let babys smash on a keyboard - so quite some focus went into capturing all kinds of weird keyboard combinations and alert messages).
I would use
<Window ... Topmost="True">
i xaml. But maybe this is not what you are looking for