c# - Can you use jQuery in WPF Applications? -
i have been creating wpf application on past few months , wanted add abit of animation application.i have been told before jquery javascript library use animation.
the problem after looking around abit there not many things on internet lets me know if possible.
i'm new jquery wont know much. if jquery isnt possible in wpf, is?
so technically can use jquery in wpf. not in way might like. web browser control load html, css, , javascript local or remote sources.
please note* did not make example scratch. comes this site
in xaml add control
<webbrowser x:name="wbmain" margin="30"></webbrowser>
and in code
wbmain.navigate(new uri("c:/myfilethatusesjqueryandhasjqueryasaref.htm"));
additionally communication between 2 possible require bit of work. have create com visible class full trust security
[permissionset(securityaction.demand, name = "fulltrust")] [comvisible(true)] public class objectforscriptinghelper { mainwindow mexternalwpf; public objectforscriptinghelper(window1w) { this.mexternalwpf = w; } public void invokemefromjavascript(string jsscript) { this.mexternalwpf.tbmessagefrombrowser.text = string.format("message :{0}", jsscript); } }
with create instance in class , access via javascript
<input type="text" id="txtmessage" /> <input type="button" value="invokeme" onclick="javascript:window.external.invokemefromjavascript(document.getelementbyid('txtmessage').value);" />
please @ article more stuff can do.
caveats
- this more not best way go new desktop application. if matter of using existing tool out of familiarity i'd consider other avenues of approach learning wpf or looking this question or one of these
if in fact out use of existing code base coded in html , javascript with offline app utilize approach recycle existing code base means @ or method or 1 of other methods mentioned using wpf animations.
Comments
Post a Comment