I have a WPF "wizard" where I am using PageFunction objects to display the various pages in the wizard. Several of these pages use references to objects in other assemblies within the application so the user can select "packages" they want to include in a generated ouput. In the page function, I have the keep alive flag set to true so that when the user presses cancel or finish in the wizard I can capture the wizard results and the corresponding data the user selected.
The problem is that the wizard pages never go away even after the scope in which they were created has been exited, Thus, when I try to remove one of the referenced objects that the wizard was databound to from a collection, it causes the wizard page to throw an exception. I cannot seem to find a way to correct this issue without setting the KeepAlive flag to false, but this breaks the ability to capture the user data from the wizard.
Any ideas?
Thanks!
I have something very similar (if not the same). A wizard created with a navigation window and a set of pagefunction pages to collect data. Some of the pagefunction pages are even pulled from assemblies in the application folder but I have never had this problem. Can you be more specific on the problem? How do you try to remove the referenced objects? Can you post some code so I can look at it?
Related
I have a Prism 4.0 enabled WPF application that uses RequestNavigate extensively, and it is working well. I have a scenario where I would like to render part of my UI to an image and store it for later use from a Windows service. I already know how to use RenderTargetBitmap to generate the image, but whenever my code tries to call RequestNavigate, nothing happens. I am calling the bootstrapper, so I would expect that all of the types are loaded, but it just is not working. Can anyone tell me if this should even be possible? Is there anything inherent to RequestNavigate that prevents it from working when there is no UI present?
Individual steps:
First, I call Run on my MefBootstrapper. This loads up all of the assemblies into the AggregateCatalog.
Then, I use MEF CompositionContainer.GetExportedValue to create a WPF UserControl that has a single ContentControl that is assigned a RegionManager.RegionName. This always creates the initial UserControl just fine.
Finally, I call MefRegionManager.RequestNavigate with the region name on my UserControl and the path to another UserControl that I want it to load. This fails to load the UserControl that I am attempting to navigate to.
If these are the only steps that I follow, then the final UserControl fails to load whether I am running from a Windows Service or from within my WPF application. However, if I call SetRegionManager to explicitely add the region from my host UserControl before calling RequestNavigate, then the last UserControl will load properly, as long as the code is run from within the WPF application. If this same code is run from my Windows service, then it still does not load.
RequestNavigate is exactly that, a request to navigate to a loaded (but inactive) region. It won't do any loading itself. You need to separately manage the loading of views (including views within views).
If your nested user control is only over loaded within the parent, and you don't need to manage it at runtime, then you can use ViewDiscovery. You register all the views in advance, and then when the region is created, it looks for (and loads) all the nested views. If you need to manage the views at runtime, switch them in and out, etc, then you can use ViewInjection.
For ViewDiscovery, in the Initialize method of the ModuleInit class in your module, insert the following line:
_regionManager.RegisterViewWithRegion("RegionNameOfYourNestedControl",
() => this.container.Resolve<NestedUserControl>());
Then when your region is loaded, the NestedUserControl will automatically be loaded into your ContentControl (region).
For more detail on ViewDiscovery, ViewInjection and UI composition, have a read of the prism documentation
I have a silverlight application that displays some values in a grid. Another part of the application updates those values and saves the updates to the source data. All of this works fine including the updating of the displayed values in the grid...until you navigate back to the page later (by say hitting refresh). Then magically all the values in the grid are back to whatever they were the first time you went to the page. I can check and verify that the data is in the source system correctly, I can also make it work fine by going into internet options and setting the browsing history to look for a new version of the page every time you visit the page. But I can't guarantee that users will do this.
I have run into this MANY times before with IE but the normal fixes don't seem to work here. I have added a timestamp to the request for the XAP file to ensure that the file is being pulled every time but somehow that is not good enough. I've also added the pragma no-cache tag to the page and still no go. It seems like Silverlight itself is it's own special case. IS there something else that can be done in the SL object to make it refresh every visit??
What code are you using to populate the grid?
If you load the data when the page is created then it will only be pulled from the database once.
If you load the data when the page is loaded or navigated to then it will be pulled from the database every time the page is displayed.
As Ken Smith says in his comment:
move your data retrieval and population code to your main form's OnNavigate event, and out of Application_Startup
This means that if you update the data and then refresh the page it should show the new values.
(I can't be 100% certain without the code)
I have been following the salesforce Recruiting App tutorial, and reached the section on creating a public site:
http://www.salesforce.com/us/developer/docs/fundamentals/Content/adg_composite_app_public_sites.htm
I have built a simple page to display open jobs as described here:
http://www.salesforce.com/us/developer/docs/fundamentals/Content/adg_composite_app_create_public_jobs_try_it_out.htm
This is displaying the open jobs correctly when I view it through our "internal" URL: https://c.ap1.visual.force.com/apex/PublicJobs
But when I view this same page through our "external" URL: http://servian-developer-edition.ap1.force.com/careers, the page still renders, except that now the list of jobs is empty.
I don't think this is a permissions error, as if so it would surely prompt me to log in. What do I need to do to make the data show on the "external" URL?
Make sure the "guest" user for the site has Read permission for the Positions object on its profile. You can't access the profile for the guest user through the normal Profile list page in Setup; instead, click on the Public Access Settings button from your site's detail page. On the profile, go all the way to the bottom of the page and make sure the Read permission is checked. If its still not working, ensure the Field Level Security settings also correct for that profile. The FLS settings are controlled about mid-way down on the same page.
In addition to above, ensure the object, if it is a custom object is in "Deployed" status. This fixed the issue for us.
Additional Information (from help.salesforce.com):
While developing a custom object or external object, you might not want users to see and interact with it. Because users might get frustrated with changes in layout or lose data when you delete custom fields, control visibility of the new object until you are finished.
Use the Deployment Status setting in the object definition to control when users can see and use the object and its associated custom tab, related lists, and reports.
Choose “In Development” as the Deployment Status when first creating your custom object or external object. Doing so hides it from users while you are designing and testing it. Only users with the “Customize Application” permission can see the object tab, search results, related lists, and report data types.
Change the Deployment Status to “Deployed” when you want to allow all users to use the object and any associated custom tab, related lists, and reports.
If you make more enhancements after deploying a custom object or external object, you can change the Deployment Status back to “In Development.”
I have a PRISM RegionManager with a couple of region - a Ribbon region on the top, and a main content region for my view underneath it - fairly basic.
The app starts with a "home" view in the main content area. When I click a button on the Ribbon, I inject a second view into the content area and navigate to it in the region manager. When I click a button on this view, it should be removed and the original view should be shown.
I'm currently doing this using the RegionManager.Add() method to manually add the second view. When I want to remove it, I publish an event which is consumed by a manager class that gets the current active remove, calls Remove() on the Region Manager for it, and then navigates back to the original view.
This all works great, except that when the second view is left alive after I call Remove(), and keeps a handle onto any subscriptions that it made during its lifetime! I've tried calling Subscribe explicitly with false for weak event references, but this is the default anyway, and it didn't help. I've tried both types of creating the view (discovery and injection) and removing the view via Remove and Deactivate. None of them helped. This is a real problem as when I want to create the same view in the future (a new instance of that view), I'm left with several instances of them, all subscribing to the same events, even though some of those instances were removed ages ago from the Region Manager.
Do I need to manually unsubscribe from every event that I subscribe to in my views (highly undesirable)? Or is there some way that I can dispose of the control / mark it as deactivated so that its subscriptions get removed?
I get the feeling that I'm doing something silly here but it's got me completely stumped.
Thanks
This is a known issue. There is a bug in the eventAggregator code. Take a look at the following blog and the suggested hack to overcome it
http://greenicicleblog.com/2010/04/28/prism-event-aggregator-more-leaky-than-it-seems/
Hope this helps
What is the best way to manage links in a Silverlight application? In my app, I have various custom controls that will open a new website in a new window.
I know in the hosting aspx page you can pass in parameters but I don't know how and where to store these links internally? Should I add a collection to the App object? Is there another mechanism that already exists? Is it a good idea to make my custom controls take the links from a global scope object or the links should be passed in the constructor?
How do you do it?
You have lots of options in Silverlight depending on what type of links they are, how many and how you want to maintain them.
If they are referenced by ID and updated occasionally, you could store them in a resource dictionary or a custom XAML file and load that on demand (XAML files are just object descriptions after all).
If you need to constantly maintain them, a database on the server would store them centrally and you would fetch them as needed via a service.
For lots in individual custom controls, that don't change links often, you could just make the hyperlink URL a property of the object and set the links in the XAML that contains the controls (this is the simplest option for the simplest usage). e.g.
<customControl Hyperlink="http://mylink.com/path/params/etc"/>
Basically it comes down to how you want to manage them. If you drop us a line via our website contact page with specific details we will be happy to provide more detailed examples/suggestions.
Hope this helps.