I have a WPF executable and I wish to make provisions to it, so that later,
someone from outside might modify or add another window or page
using dll totally separate from my solution.
For short, I wish to make my wpf windows or pages pluggable. How do I do this?
Prism's support modular, on-demand-loading of modules and other parts of your application, in it's core.
you can use MEF framework to make pluggable modules (windows and pages), as it's fully integrated with Prism.
You can find examples and more information in the following resources:
http://www.codeproject.com/Articles/188054/An-Introduction-to-Managed-Extensibility-Framework
http://www.codeproject.com/Articles/37579/Managed-Extensibility-Framework-Part-2
http://www.codeproject.com/Articles/432069/Simple-MEF-Application-for-Beginners
http://www.codeproject.com/Articles/232868/MEF-Features-with-Examples
Related
I am currently working on an enterprise WPF application and I am experiencing some issues with static resources: globally defined styles and converters.
The application works this way:
There is a shared host WPF application that is used as host for components developed by different teams (it's a PRISM application and MEF is used for importing plugins)
Each team can add plugins by creating new dlls, but cannot modify other teams' dlls
No changes can be made to the host application
My team is in charge of few plugins and we need to add more functionalities but we are wondering what is the best way to solve our problem.
In a simple (standard?) WPF application, we would have styles defined in the App.xaml file and all the xaml UserControls or Windows would be able to link to them at design time easily and of course at runtime.
But now, while I managed to get the styles to work during runtime, I cannot have them working at design time and it is causing two major issues:
I cannot see how things would look like in the IDE
When I reference a converter the IDE complains but I have no way to know how wether it will work at runtime or not.
How do I get StaticResources to be imported and, at the same time, work in my IDE?
If not possible, what other strategies can I adopt to overcome these issues?
If I understand you correctly you want to use your "Design" tab in Visual Studio to see style changes and check the look and feel of your WPF application.
If that is the case, I will disappoint you but I haven't met any WPF developer yet using the 'Design' instead of 'XAML' view to make changes etc. in more advanced applications. Unfortunately the "Design" view has many flaws, doesn't display the Views properly, has problem with static resources converter and what is more it is always resource hungry.
The way we are working with WPF applications is building them and inspecting the problems and changes using a Snoop utility to investigate the application, binding errors, style problems, etc. I have never seen a way to use the build in "Design" view without many flaws, hacks and performance issues.
What is more, you should write a fake host application so that you will be able to run your plugins without the need of running the main app (if that is a problem for you)
I have a simple WPF user control:
<StackPanel>
<Button>Test</Button>
<TextBox>Test</TextBox>
<TextBlock>Test</TextBlock>
</StackPanel>
I am hosting this user control inside Windows Forms host. Silk Test identifies this entire user control as Element-Host only and is not able to identify individual buttons or text-boxes.
Has anybody more insight on this? Is this scenario supported by Silk Test?
Update :
I have little success with Silk Test 14.0 (Earlier i had 13.5). Created test application with similar structure (WPF Control in windows forms host) and checked with Silk Test 14.0. It is able to detect all individual WPF controls within user-control . But with my application, it is still not able to detect controls apart from 2 combo-boxes in "Toolbar". In user-control, i am using custom grid which is derived from Data-grid class
This should work.
It might depend on how you are embedding the UserControl though.
In the application we are using for testing it is contained in a Windows Forms ElementHost-control.
In the code-behind you should see member declarations for both the ElementHost and your UserControl, is this the case?
Is your application using multiple AppDomains? Silk Test currently only supports multiple AppDomains for Windows Forms, not for WPF so this might be another reason why it isn't working for you.
I don't know Silk Test well but it seems to me that this tool supports only standalone WPF applications. In your case, there is a standalone WinForms application with embedded WPFs controls. Documentation says:
Silk Test Workbench provides built-in support for testing Windows Presentation Foundation (WPF) applications. Silk Test Workbench supports standalone WPF applications and can record and play back controls embedded in .NET version 3.5 or later.
Silk Test team has identified this to be a bug. Fix may be released as a patch over Silk Test 15.5 version. I will update this post once i have better details on its release.
Here's the situation:
We have an existing .NET executable that contains an application using WPF components (dialogs and forms). This executable was created using Gupta Team Developer 6.1, but I'm not sure that is relevant to my question. We'd like to re-use some of these forms in a C#-application, but this is proving difficult.
When we include the external components, either in XAML or by instantiating them in code, they look OK (i.e. fields, buttons, layout etc.), but the event wiring seems to be missing. Nothing happens when pressing buttons and tables/grids are empty.
I've read previous articles on this site on using external WPF components, but they all mention external assemblies compiled as control libraries. Are we trying to do something that's not really possible?
P.S As an experiment we've tried to instantiate the App-object from the executable directly and this brings up a fully functional version of the entire application (well, duh), but we'd really like to be able to pick and choose from the individual forms/dialogs.
Out of curiousity, is it possible to have 2 application layouts without having to have 2 projects?
Like one layout for desktop/laptops. And then one layout for tablets?
I know winforms only has 1 designer file, and that probably answers my question, but I was curious if i really just needed to re-create a whole new program for a tablet layout, even though it would have all the same functionality as the desktop, with all the same controls, just look slightly different.
I'd put the core functionality in a library assembly (DLL), and write two UI applications that reference the same core assembly.
You can write your own custom LayoutEngine which handles the layout. This way you leave all layout oriented task to your engine and can focus on code.
Here's an article on Microsoft on how to do this (with sample source):
http://msdn.microsoft.com/en-us/library/ms973821.aspx
From the article:
All Windows Forms controls provide a Layout event, along with a host
of other notifications, which enables the writing of a complex layout
code. To facilitate writing reusable layout engines, we can provide a
basic framework.
I'm designing a WPF program that will use a DLL-plugin architecture. The host application is more "chrome" than content. It's in charge of providing a consistent look and feel, as well as providing some features common to all the plugins (Such as a "Check for updates" button).
However, my plan is that 3rd party developers will code the plugins. As such, they will need to add plugin specific functionality. I've designed the host application so that it allocates a tab page (or two, if the plugin requests it), and will allow the plugin to fill that tab page with its own buttons, listboxes, ect, which will then trigger the appropriate code in the plugin.
Kind of like MDI, except that the buttons will be hosted in the host application's tab page, but will trigger events in the plugin.
I need some help figuring out how to implement this design. What do I, as the host-programmer, need to do to support this (Such as loading the plugin and filling the tab page)? What will the plugin developers need to do to
"Embed" their WPF in my tab page
Catch events generated by their embedded controls
Get this into a DLL
Check WPF Add-Ins architecture. Here is a sample.
Much of the boilerplate stuff needed to implement a plugin architecture can be found in the Managed Extensibility Framework:
http://mef.codeplex.com/
As for hosting buttons on the Host that will trigger events in the client page, you can achieve this by executing a specific command with the client page set as the Target. Here is an example of executing the 'Paste' command on a Page called "hostedWpfPageControl":
ApplicationCommands.Paste.Execute(null, this.hostedWpfPageControl);