Ajax Style Loading Animation in Silverlight - silverlight-3.0

I am building a Silverlight application around the new Navigation framework. Due to the nature of the application, there will be quite a bit of waiting around.
To that end, I'd like to add an Ajax-style loading animation to all my navigation pages. In other words, while I go and get the data for any of the pages, I want to be showing the loading animation.
I can't seem to find any up-to-date examples?

You may want to take a look at the Activity control.

I think to achieve this is to use the BusyIndicator.
You would reference this:
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
Then use the BusyIndicator like this (please note of the binding).
<toolkit:BusyIndicator x:Name="busyIndicator" IsBusy="{Binding Path=IsBusy}">
<toolkit:BusyIndicator.BusyContent>
<StackPanel>
<TextBlock >Fetching data...</TextBlock>
<Rectangle RadiusX="10" RadiusY="10" Fill="#80000000" />
</StackPanel>
</toolkit:BusyIndicator.BusyContent>
....... XAML Code here
</toolkit:BusyIndicator>
Then on your ViewModel you raise the IsBusy property whenever you would call a service to fetch a data or whatever process needed (I'm using the GalaSoft.MvvmLight).
RaisePropertyChanged("IsBusy");

Related

How to close/dismiss modal while still resolving?

I'm looking for a way to cancel the resolve of a Angular-UI Bootstrap modal and stop it from opening. The dismissAll method is not working because the modal instance is added to the modal stack only after the resolve has completed.
I have a website where modals open and close on route change. If dismissAll is called during route change to close any old modals it won't affect modals that are still resolving. So you come to the new route but the old modal still pops up after its resolve has completed.
As things stand right now, there is no way to cancel ES6 and $q promises. you can refer to this question for more info.
tl;dr Bluebird allows promise cancellation
If you really need it you can add bluebird to angular.
If you still want to use plain ol' $q, here's what I would have done
Pass the modal the current state (if using ui-router) or route (if using angular router).
When you need to render the modal template compare the current state to the provided state.
If they are not equal discard the modal
The modalInstance object exposes a rendered promise that will run when the modal finished rendering, you can place $uibModalStack.dismissAll(); inside.
Example:
modalInstance.rendered.then(function (currentState) {
if (currentState !== $state.current) {
$uibModalStack.dismissAll();
}
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
Of course you can defer your loading after rendering the modal and avoid this mess altogether.
This is by far the simplest way to make sure modals never stick around, and it works for apps with simple modal use. I’ve seen this working for years at several places and reliably. Essentially, you register a state change listener in your router and whenever there’s a state change you make sure to dismiss all open modals, whatever those might be. Again, this might seem harsh, but in some apps this works like a charm, and is better than nothing.
A simple example, using UI Router’s $transition service and Angular UI Bootstrap’s $uibModalStack, this can be as simple as:
$transitions.onFinish({}, function(transition) {
$uibModalStack.dismissAll();
});
And of course, if needed, you can only perform this for transitions that match a specific criteria.
Source: https://www.codelord.net/2017/12/11/reliably-managing-modals-in-angularjs/

How to define style resources for specific control in Xamarin.Forms?

I am newbie to Xamarin and Xamarin.Form, basically I want to define style for the controls.
Like when I place Label control then it should follow the same style throughout the page. I've read somewhere on article that it can be done by defining styles in tags but don't know how..
How to define for 1 page
How to define globally which will be applied to all the pages
How to define device specific
Can anyone provide some example code / link for same?
Thanks in advance!
If you are talking about doing it through XAML then:
- if it is per page then go with resources.
- for device specific, use OnPlatform class
- there are no global resources currently
If you are creating your stuff in code then apply whatever global value you wish when you create them. If there are platform specific values then use Device class.
HTH
For per page resources, you can create a Common folder with files such as "ColorResources" which might have entries such as
public static readonly Color ActivityIndicator = Color.Blue;
You can then use that in your XAML like this
<ActivityIndicator IsRunning="{Binding IsLoading}"
Color="{x:Static common:ColorResources.ActivityIndicator}" />
(Remember to declare your common namespace)
For cross page, I'd recommend a custom renderer, built from the original control but tailored to look like what you want. You can find out more hereCustom Renderers

ASP.NET MVC ActionMethodSelector dependency injection/replacement

I wish to replace the implementation of System.Web.Mvc.ActionMethodSelector as used by the FindAction method of ReflectedControllerDescriptor, but would like to take advantage of the existing implementation, ideally by deriving from ActionMethodSelector. However, because the class is marked as internal the only way I can see to do this 'properly' is to derive from ReflectedControllerDescriptor and implement FindAction by copying the code from ActionMethodSelector. I wish to avoid this however due to the quantity of code, and potential issues trying to keep it up to date with the framework.
I'm considering the following approaches:
Biting the bullet and copying the code
Using reflection so as to take advantage of the existing implementation
Are there any other approaches that I'm missing, better or otherwise?
I know it is a bit late to answer still I am giving it a try.... :)
I believe that you somehow want to tweak action method selection process in ASP.NET MVC. If my understanding is correct you can make use of custom ActionMethodSelectorAttribute by deriving from System.Web.Mvc.ActionMethodSelectorAttribute. Write your own custom logic in the custom selector and apply it on the top of the action methods. I believe in this way the action method selection process can be tweaked without disturbing the natural process.
If you wish you can visit these links: http://programersnotebook.blogspot.in/2014/02/aspnet-mvc-actionnameselector-and.html, http://programersnotebook.blogspot.in/2014/02/aspnet-mvc-actionnameselector-and_2.html

How to Call a java function in JSF navigation throgh <to-view-id>

<navigation-case>
<from-action>#{tabViewController.openscreen}</from-action>
<from-outcome>Group Master</from-outcome>
<to-view-id>#{tabViewController.openscreen1}</to-view-id>
</navigation-case>
in the , i want to call a java function because i need to open a screen in tab controller.
I guess you come from a framework that has this functionality? As in Pageflows from seam.
JSF-2.0 does not have this afaik. But if I understand you correctly you want to execute a method when a view gets loaded.
This is usually done with either:
<f:event listener="#{user.isAdmin}" type="preRenderView" />
full example: http://www.mkyong.com/jsf2/jsf-2-prerenderviewevent-example/
Or by using JSR-250 and the annotation #PostConstruct.
A method annotated with it will be executed after injections and it's a very useful annotation for your use case and afaik it's best practice in most cases.
Good luck.

How do you unwire an action in Nitrogen?

In Nitrogen, the Erlang web framework, you wire actions like this:
wf:wire(send_message, #event { type=click, postback=send_message })
but if after that you run
wf:wire(send_message, #event { type=click, postback=send_message2 }),
then you get the action wired twice.
How do you unwire the previous action or all actions of an element?
Since events in nitrogen are bound using jquery's bind method. You can use unbind to unbind them. There isn't currently a nitrogen api to unbind an event but you could output the javascript code to unbind it yourself if you so wished.
see action_event.erl for an example of how the binding javascript is output. You can create a similar action/event that removes the binding.
I too was looking for an "unwire" and didn't find it. My work-around was to wf:replace() the element to which the event was wired, and wire the replacement element; I hope that javascript will eventually notice the former bind can never be called and then garbage collect it. I don't know how expensive such abandoned bindings are. My context was a lazy loading of the page, such that a button would initially show a stub, but when clicked would download arbitrarily large content, and henceforth toggle hide/show.
Beyond being nervous about the sophistication of the javascript garbage collection, I'm worried that this may be a bad pattern, and would love to hear others' experience. The only alternative that occurs to me would be to keep state (e.g. data) in the original element and pass that state back with the event message so that the same event handler would act on the "unloaded->loaded_show->loaded_hide->loaded_show" transitions. But I'd prefer not to be calling back to the server for a simple hide/show transition.

Resources