Silverlight desktop browser? - c#

Is it possible to build a silverlight desktop web browser?
(just for fun, to see if it works etc) :)

I don't see why not.
With Silverlight 4 you can build a full trust application utilising a Web Browser Control (Source).
There's more details on the WebBrowser Class on the MSDN.
Hosts HTML content within the Silverlight plug-in.

Yes you can. Using WebBrowser control is not fun and defeats the purpose of writing a browser. Basically you would have to load raw html and parse it into DOM-like data structure. Next you'd have to use Silverlight visual elements and layouts to render html page as close as possible to the way real browsers do it.
You're likely to run into Silverlight limitations in process and creating browser compatible with CSS3 would require huge amount of work, so while in theory it should be possible I'd just stick to that knowledge and not try to actually do it.

Related

Deploy a WPF user control in a Silverlight application

I have developed a user control in WPF which draws some graphs.
Now i have to show this user control in a Silverlight application (to show on ASP.net webpage).
Is this possible to use a WPF user control in a Silverlight application?
I have searched on Google, but have not found a satisfactory answer.
No, it is not possible to show a WPF control in Silverlight. They use two different runtimes so are not directly substitutable with each other.
You have a few options though:
use XBAP to show WPF within the browser
rewrite your control so that you can compile a version for Silverlight or WPF (this is (was) quite a common way to do it)
Edit:
in response to your comment you seem to have some misunderstandings, I think you haven't understood the links I gave you. You may also have misunderstood what Silverlight is - just in case you have let me mention that Silverlight runs as a plugin within the web page, it isn't directly part of the HTML structure.
For the XBAP approach the WPF control/page is hosted inside a web page - just like a Silverlight control is. However you don't have direct access to the local filesystem or network filesystem (or databases running on the network) - Silverlight is the same, to access a database you really need to go via a WCF service.
With the second approach you have two versions (one for WPF, one for Silverlight) of your control and you use compile time targeting to dictate which control is built. You then use the appropriate control in the appropriate project.

Use WPF Controls in Web project

I created another WPF project in my asp.net project solution and now want to use my WPF controls in my web application. Is it possible to use wpf control in my web projects?? I figure out on internet some says like you have to use Silverlight for web applicaitons. As far I know silverlight is subpart of WPF, so why not i can use WPF??. I have to use WPF controls because already did enough efforts to build wpf controls and now wanna to use in Web application.
Yes, you can embed WPF controls in a webpage, but you'll need the relevant plug-in enabled (much like Silverlight).
As an example the Xceed Datagrid for WPF is viewable within Internet Explorer.
Although XAML applications are disabled by default, you'll need to enable them in your Internet Explorer security settings.
As for Firefox, you'll need both the .Net Framework Assistant, and WPF Plugin as suggested by MSDN.
WPF is a really great framework, and enabling WPF/XAML based applications for intranet usage would be fine (you could inherit the security permissions through group policy), or for a set audience who don't mind the extra configuration.
The only way you can achieve that is by using Silverlight components not WPF. As you said silverlight is a subset of WFP, so not all WPF features are supported but the silverlight runner. For the most part, the visuals are fully compatible, that is user controls, so if you did not use anything that is specific to WPF then you should be grand.
maybe check here:
WPF vs Silverlight
BTW can you post your xaml, so that we get an idea?
Marco
I believe you can use the XML WPF Browser application to do this, but I'd probably not recommend it, as I think your users will have to download client-side components in order for it to run. The following link gives more info.
http://msdn.microsoft.com/en-us/library/aa970060.aspx
No you cannot use WPF in a web page. WPF is for Windows Applications and will only run on Windows machines. The internet is device agnostic and will run on Windows, Linux, Android, iOS etc. Therefore you need to use ASP .NET (or similar) for web applications and WPF for Windows.
Silverlight is a sub-set of WPF and will work on a web page... BUT not all devices support it (i.e. iOS). So if you really want to be system agnostic and true to the spirit of the web use HTML / CSS and JavaScript.
Whatever it is possible or not, the using of WPF controls embedded in a html page is just horrible.
A classic WPF control might be running (after changed browser settings), but there are many security concerns. Furthermore you have to show your users a to do list before anyone could see the real page.
Silverlight as a subset of WPF, but it is also a plugin that is not available for all platforms such as, for instance, iOS.
I recommend to use HTML 5, which is a per se standard and viewable on all other platforms. It causes more effort, but is is definitely worth it.
Although there are ways to do this (already mentioned by other users on this page), relying on your visitors to have this configured or plugins installed in their browsers means it's very risky to implement this (assuming your target is the WWW and not just local users).
I would consider building a web application UI and just reference everything via class libaries (if using N Tier design)

Get value of Label in ASP.NET website from C# windows form application

I am developing web browser in C# windows form application using WebBrowser component.And also a website in ASP.NET using C#.Both are different projects.How can i use value of Label from windows form application and use the same value in ASP.NET website?
Help me !
Thanks in advance !!
Did you know you can write code to automate browsers, such as IE or Firefox? I mean, write code to launch a browser window, load pages at will, easily access particular parts of web pages, simulate user input (textboxes, controls, buttons, etc). It's commonly used to automate testing of web pages, and what-not.
There are multiple libraries out there, but I personally tried WatIn: http://watin.org/. Open source (free), .net component, easy to use, ton of examples.
I'm suggesting this as an alternative - if it fits your model. I know this doesn't answer your question; sorry.

Pulling data from an ActiveX control in Internet Explorer 8

I'm being slowly driven mad at work having to manually gather data contained within an ActiveX object running in Internet Explorer 8. It's essentially a ticket system containing some key customer details etc. which I must copy and paste a lot more than is healthy.
Where would I start looking for a solution that will allow me to grab the data I want and navigate the ActiveX system programmatically?
Ideally I'd be thinking of writing something in Java or C# but I'm open to any suggestions!
Unless the ActiveX you are interested in exposes information through public interface (in which case you can injected JavaScript on page to read data) you'll have to use some form of screen scraping. If the control has regular input controls it should not be too hard, but if everything rendered directly you may need OCR the images...
Injecting script:
use WebBrowser control and "eval" your script on the page - some communication sample is here http://msdn.microsoft.com/en-us/library/a0746166%28v=VS.85%29.aspx, eventually you'll need InvokeScript - http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.invokescript%28v=VS.85%29.aspx
use normal IE automation http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx.
for one-time use "javascript:" in address bar or just developer tools (F12).
utilize XSS vulnerabilities of the site (half kidding, don't forget to fix whatever you find afterwards if you own the site, as for reporting errors to third party consult your conscience)

Use a webpage as the UI in a C# desktop application?

I'm building a C# desktop app with a simple UI. Due to my familiarity with HTML/CSS, and a previous web-based iteration of a very similar app, it would be ideal if I could re-use some existing HTML/CSS pages I have as the UI for this new desktop app.
Is that do-able with C#? Can anyone show a simple example of using an HTML/CSS page as the UI of a C# desktop application?
Other answers are dated, new good options:
Electron + Electron-Edge - is the way to go for a new Electron app that communicates to a .NET backend (a DLL). Widely used and supported.
Neutronium - best for already-written .NET WPF apps that need a HTML UI. Requires using Vue. Less popular and less supported.
CefSharp (https://github.com/cefsharp/CefSharp) is a good way to embed chromium, but you still need a web server. Take a look at http://www.ultidev.com/products/Cassini/ to alternative for IIS.
You can use WebBrowser control to add Web browser functionality to your application.
You can create your own html(s) and set your WebBrowser control to display those pages. You can navigate by clicking hyperlinks or by using keyboard shortcuts to move backward and forward through navigation history. By default, you can access additional browser functionality through the right-click shortcut menu
You can even manage those pages centrally (for e.g. on LAN) and all clients on LAN can connect to this central location. This way you can modify pages centrally.
Check a walkthrough on MSDN:
How to: Add Web Browser Capabilities to a Windows Forms Application
You can try to use a Chromium-based control - DotNetBrowser. This control provides wide interactivity options, like DOM manipulation and DOM events, which can be useful in your case.
In addition, there is an article that demonstrates how to use a web page as HTML UI in a C# desktop application: https://www.infoq.com/articles/html-desktop-net
Affiliation disclosure: I work with the team, which created DotNetBrowser.
You could try adding a Web Browser control to a forms application to show your page. But this will need to be remotely hosted as the code will not be able to execute locally, except if you listen for the specific links in c# and then perform the actions.
You could also try your hand at WPF which is a new technology to create good looking gui's with mark-up much like html, which you'll pick up pretty quickly with your html experience.
Unfortunately neither WinForms or WPF is sufficiently like HTML/CSS to be of that kind of use. You'll be able to reuse the layout-concepts and art of course. And, with WPF being the closest thing to it, you might even keep a lot of the code-behind code.
But the short answer is: No

Categories

Resources