WebView containing Silverlight - silverlight

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.

Related

C# wpf weird repaint issue

I have experienced this intermittent issue with WPF.
Sometimes, when a Window is shown, it will have nothing except maybe a button visible. And after moving your mouse around and clicking on the window, the rest of it will become visible.
I don't know if this is an issue with WPF or maybe the UI library I am using.
Anyone has seen something like this?
Thank you.

WPF Usercontrol performance vs window performance issue

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.

Is there a SurfacePopup control in Surface 2?

We've been working on an application for the last few months that's aimed at Windows 7 tablet PCs. So we've used the Surface 2 SDK for most controls and it's all touch-happy.
I have noticed recently, though, that one of our custom controls isn't working as it should. This control provides popout menus, and these are achieved through the Popup control. On a developer's laptop, this works fine and the menus vanish when you click away from them. I've noticed, though, that on our test tablet they have a tendency to stay open.
I found that there was a SurfacePopup in the first Surface SDK, but I can't find one in the Surface 2 SDK. Did they get rid of it? Is there a 'best practice' approach?
If there's no simple solution, I may have to go old-school and add a window-sized hidden SurfaceButton below the menu when it appears, that hides itself and the menu when clicked or touched.
Beyond that I've noticed that sometimes the SurfaceScrollViewer within the popups won't work. I'm guessing this is because it's not picking up touch events properly. I tried adding this extension method to the window..
this.EnableSurfaceInput();
..but I get a NullReferenceException on System.Windows.Input.Mouse.get_LeftButton() which bizarrely suggests that it can only enable surface inputs for controls when there's a mouse plugged in.
Any ideas? They'll all be welcomed with open arms!
There's no SurfacePopup in the Surface SDK 2.0, however you can use a normal WPF popup. Then you need to make sure that it receives Touch Events by using the extension method you suggested above on the popup, not the window:
((HwndSource)HwndSource.FromVisual(popup)).EnableSurfaceInput();
Edit: As I just found out, this only works when the popup is initially open. To get it to work when the popup is opened later on, you don't need to use the popup, but the parent of it's child (see this question).
For the benefit of Daniel, and anyone else who needs a solution to this, I'll try to cast my mind back two years and explain how we got this working.
As far as I can remember, the answer was to use an adorner layer instead of a popup. Basically, every WPF control has an adorner layer, which sits above the control's UI stack. By default it contains nothing, but you can add whatever you like to it.
I got this all working by writing a custom control that allows you to place that control, with content, in the XAML and then show and hide it whenever you need to. When it's shown, it moves its contents into the adorner layer of the containing window, and when it's hidden it moves the contents back into the control itself, which is hidden from the user.
Afraid I can't go into any more detail than that, but as far as I can remember this was the ultimate solution; replacing popups (which never quite worked very well) with a custom control that uses the adorner layer.
Hope that helps!

SketchFlow WP7 Navigation Buggy

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.

Track "commands" send to WPF window by touchpad (Bamboo)

I just bought a touchpad wich allows drawing and using multitouch. The api is not supported fully by windows 7, so I have to rely on the build in config dialog.
The basic features are working, so if I draw something in my WPF tool, and use both fingers to do a right click, I can e.g. change the color. What I want to do now is assign other functions to special features in WPF.
Does anybody know how to find out in what way the pad communicates with the app? It works e.g. in Firefox to scroll, like it should (shown on this photo). But I do not know how to hookup the scroll event, I tried a Scrollviewer (which ignores my scroll attempts) and I also hooked up an event with the keypressed, but it does not fire (I assume the pad does not "press a key" but somehow sends the "scroll" command direclty. How can I catch that command in WPF?
Thanks a lot,
Chris
[EDIT] I got the scroll to work, but only up and down, not left and right. It was just a stupid "listbox in scrollviewer" mistake. But still not sure about commands like ZOOM in (which is working even in paint).. Which API contains such things?
[EDIT2] Funny, the zoom works in Firefox, the horizontal scrolling does not. But, in paint, the horizontal scrolling works...
[EDIT 3] Just asked in the wacom forum, lets see about vendor support reaction time...
http://forum.wacom.eu/viewtopic.php?f=4&t=1939
Here is a picture of the config surface to get the idea what I am talking about: (Bamboo settings, I try to catch these commands in WPF)
alt text http://img340.imageshack.us/img340/3751/20091008210914.jpg
Have you had a look at this yet.
WPF 3.5 does not natively support multi-touch (it is coming in WPF 4.0) however the samples in that kit should get you started using the Windows7 Integration Library which access the native Win32 APIs to provide the required support (Don't worry its not real ugly:).

Resources