I have a main ViewModel and a UserLoginViewModel. From the User view model I need to show a prompt with Ok/Cancel options. I've done it as stated in this link http://www.deanchalk.me.uk/post/WPF-MVVM-e28093-Simple-e28098MessageBoxShowe28099-With-Action-Func.aspx . To avoid Invalid-cross thread exception i used a dispatcher. The code is something like this
mainDispatcher.BeginInvoke(new MessageBoxDelegate
(
(message, title) => { Popup(msg, ""); }
), messageArgs);
where mainDispatcher is the dispatcher of MainView and Popup is of type Func<string, string, MessageBoxResult>
And it works fine. The problem is that I cannot get the results from the BeginInvoke Method. Is there is any way to get the result from the BeginInvoke method?
If is there is not, any suggestions how i can implement this?
I am not sure how it fits into the MVVM model, but I would suggest you to use the code4fun's MessagePrompt instead of a MessageBox
Obviously you get the result with a var result = Popup(msg, "");
You need to evaluate the result within BeginInvoke() because any code below BeginInvoke() runs before BeginInvoke().
Related
I want to navigate using RegionManager
regionManager.RequestNavigate("TabsView_region", "TabsView");
But it seems I've done something wrong, and nothing happens.
I'm sure that I registred TabsView for navigation. I've checked several times names of parameters. ViewModel of TabsView is connected with View through AutoWire. ViewModel implemets INavigationAware. I even created an empty project, where I simulated the same situation and in this case RequestNavigate works fine.
The question is if there is a way to get information, why navigation doesn't work?
Are you looking for
regionManager.RequestNavigate("TabsView_region", "TabsView", result => { if (!result.Result) MessageBox.Show(result.Exception.ToString()); } );
?
I have a situation where I need to disable the button(added as widget for widget column) when I receive one web socket event. When receiving the web socket I might be in any page. So how to get the reference of that button widget and disable it.
I have created a fiddle WidgetTestFiddle
Can anyone please help.
Thanks in advance
You could use the Ext.ComponentQuery.
Using the query method you can search for the buttons inside your grid.
You probably want to give your buttons an itemId (e.g. itemId: 'widgetcolumn-button-switch') to ensure that you only find the buttons you want.
Using the itemId your search query would look like this: 'button[itemId="widgetcolumn-button-switch"]'
I forked your fiddle and created my own version to illustrate my point: Sencha fiddle example
I think there are several ways to achieve your wanted result.
KaMuns answer will work, but can be tricky in case you use a buffered store / grid. Because the pages in this case are handled internally by the store. Using a static itemId wont work in this case out of the box.
I would suggest you rely on the record data.
Everytime you recieve a websocket message, update the store and refresh the grid view can be an option.
I have modified your fiddle here:
https://fiddle.sencha.com/#view/editor&fiddle/3a87
Here are is the most relevant part:
var grid = btn.up('grid');
var models = grid.getStore().getData().getRange(); // of cause you can use find or another way here
var model = models.filter(mod => mod.get('actualRole') === 'Follower');
model[0].set('showBtn', false);
grid.getView().refresh(); // get ref to view and refresh because data changed
On top you can have a look on the defaultBindProperties and may change this to the hidden key of the button.
I would like to a pass a record from a grid to a window that I create,
Ext.create('MyWindow',
{recordRef: record}).show();
where record is an argument that is passed into my rowdblclick function but when I try to access recordRef (like below) during debugging, it is undefined.
var me = this;
var record = me.getView().recordRef;
The code fragment above is in a controller for MyWindow.js
The reason this is happening is probably because you are using an event to access recordRef that is called before the constructor assigns recordRef to your window as a property.
My advice would be to use the show event just to be sure, here is a fiddle: https://fiddle.sencha.com/#view/editor&fiddle/232m
You can access custom configs you add to a component with getConfig - in this case it would be this.getConfig('recordRef')
Here's a small fiddle where the custom config is logged to the console, and set to be the window's title.
First sorry for my bad English.
I'm new on Ionic and I'm trying to pass my app from background to foreground when local notification trigger. I'm using the Katzer API (https://github.com/katzer/cordova-plugin-local-notifications), and I want to show a view (skype style incoming call) for stop or postpone a notification. This example works ok, but I need a method or something in order to show the postpone screen even when the screen is locked.
cordova.plugins.notification.local.on('trigger', function (notification) {
alert("triggered");
}
Thanks in advance.
After more deeper researching I managed to do it, so I'll answer to myself and leave it here for anybody who needs it.
If you want to show your application in foreground when the notification is triggered you should modify the AbstractTriggerReceiver.java
I added this method in AbstractTriggerReceiver.java:
public void launchApp() {
Context context = getContextForApp();
String pkgName = context.getPackageName();
Intent intent = context
.getPackageManager()
.getLaunchIntentForPackage(pkgName);
intent.addFlags(
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent);
}
So in your TriggerReceiver.java you can call launchApp(); in your onTrigger() method.
There isn't an easy solution for this, since you need to work mainly in the native layer.
E.g. In Android you should create an activity visible over the default lock screen, show it when the notification is triggered and start the Cordova activity on a button click.
I have a text field that is apparently successfully calling delegate methods as the following method fires when I tap on the test field, but no keyboard shows.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
NSLog(#"should begin editing");
return YES;
}
Any ideas as to why?
A couple of details: This text field happens to be in a view controller in a storyboard. The first time I segue to this view the text field works fine. The subsequent times I segue to this view it does not work. I imagine this is a big clue to why I am getting the described behavior, but I have not been able to figure it out yet.
I fixed the issue by adding the code below to the prepareForSegue: method. Seems to work.
if (_textField.isFirstResponder) {
[_textTextField resignFirstResponder];
}