event-handling

Event fires more and more times

若如初见. 提交于 2020-01-09 07:57:22
问题 I have a silverlight mvvm application that loads main view with 2 user controls loaded into 2 ContentControls, one with listbox showing items and other with edit button. When i click edit button, 2 new user controls load into the ContentControls, one showing data to edit (EditData) and other having Save and Cancel button (EditAction). When i click save button, it raises an event that is defined in seperate GlobalEvents.cs class like: public event EventHandler OnSaveButtonClicked; public void

C# Cancel Windows Shutdown

天大地大妈咪最大 提交于 2020-01-09 05:26:29
问题 i want to my application can prevents from windows shut down. i know that there is a system command to do that. but don't work for my program. i use this code for "cancel" the windows shut down: private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason.Equals(CloseReason.WindowsShutDown)) { MessageBox.Show("Cancelling Windows shutdown"); string cmd = "shutdown /a"; Process.Start(cmd);// for executing system command. } } and also use this code, but does not work

Child elements of scrollviewer preventing scrolling with mouse wheel?

六月ゝ 毕业季﹏ 提交于 2020-01-09 04:38:08
问题 I'm having a problem getting mouse wheel scrolling to work in the following XAML, which I have simplified for clarity: <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" CanContentScroll="False" > <Grid MouseDown="Editor_MouseDown" MouseUp="Editor_MouseUp" MouseMove="Editor_MouseMove" Focusable="False" > <Grid.Resources> <DataTemplate DataType="{x:Type local:DataFieldModel}" > <Grid Margin="0,2,2,2" > <TextBox Cursor="IBeam" MouseDown="TextBox

How can I add an event handler to an event by name?

匆匆过客 提交于 2020-01-07 04:56:08
问题 I'm attempting to add an event handler for every control on my form. The form is a simple info box which pops up, and clicking anywhere on it does the same thing (sort of like Outlook's email notifier.) To do this, I've written a recursive method to add a MouseClick handler to each control, as follows: private void AddMouseClickHandler(Control control, MouseEventHandler handler) { control.MouseClick += handler; foreach (Control subControl in control.Controls) AddMouseClickHandler(subControl,

How can I attach an react to user clicking on tabs in Ext.TabPanel

て烟熏妆下的殇ゞ 提交于 2020-01-07 04:54:31
问题 When I want to react to the user selecting a row on a grid, I use this: var grid = new Ext.grid.GridPanel({ region: 'center', ... }); grid.getSelectionModel().on('rowselect', function(sm, index, rec){ changeMenuItemInfoArea(menuItemApplication, 'you are on row with index ' + index) }); how can I attach the same functionality to tabs? something like this: var modules_info_panel = new Ext.TabPanel({ activeTab: 0, region: 'center', defaults:{autoScroll:true}, listeners: { 'tabclick': function

Event Handler is executed more than once

家住魔仙堡 提交于 2020-01-07 02:52:11
问题 When I use this snippet of code The MessageOutput.Text is set 2 times, which means that the code is executed twice since I don't set the MessageOutput.Text anywhere else. Whenever I get a new message, this method is called and it is supposed to update the UI. Why is this happening and how can I fix it? async void MessageReceived(DatagramSocket socket, DatagramSocketMessageReceivedEventArgs eventArguments) { uint stringLength = eventArguments.GetDataReader().UnconsumedBufferLength; string

C# Passing data to the original thread from Timer

若如初见. 提交于 2020-01-07 02:47:34
问题 This question is possibly a duplicate of How do you add a timer to a C# console application and few other similar questions but couldn't find the answer I'm looking for so asking again. Question : How do you pass data from the Elapsed event of a Timer ( System.Timers.Timer ) to the thread that created the timer (that thread may not be the Main thread but another thread spawned by Main )? I assume there could be some trivial way of achieving this eg. like the BackgroundWorker ProgressChanged

Laravel 5.2 : How to call “sendFailedLoginResponse” from custom Login Event Handler?

你。 提交于 2020-01-06 23:48:51
问题 In Laravel 5.2, there is a function already overriden in my AuthController.php : public function sendFailedLoginResponse() { $errors = new MessageBag([ 'email' => ['Error message for email'], 'password' => ['Error message for password'], 'mycustominput' => ['Error message for my custom input field'], ]); return redirect()->back()->withErrors($errors); } This alone works (like magic) via normal FAILED login attempts. (When login is failed, the login form already shows this custom error

Keep track of object ids properly after creating elements with ng-repeat

我的梦境 提交于 2020-01-06 21:22:19
问题 I have created a list of items with an object inside my controller $scope.devices = [ {"id": 0, "name": "sw", "class": 'sw' }, {"id": 1, "name": "mlr", "class": 'mlr'}, {"id": 2, "name": "lvm", "class": 'lvm'}, {"id": 3, "name": "ltc", "class": 'ltc'}, {"id": 4, "name": "fr", "class": 'fr'}, {"id": 5, "name": "cap", "class": 'cap'} ]; and ng-repeat in my HTML <li ng-repeat="device in devices" ng-click="selected(device.id)"></li> I can keep track of an item that is clicked with $scope.selected

Failed to set event handler in javascript

时光怂恿深爱的人放手 提交于 2020-01-06 19:32:42
问题 This question is a follow up of post Failed to set event handler in javascript I want to add an event handler for input text controls. The input box control is generated dynamically. My code is like: _inputbox = document.createElement("input"); _inputbox.type = "text"; _inputbox.id = settings[zindex]; _inputbox.onblur = checkName; checkName() is defined previously. But when I input something in the box and move the focus to other control, the checkName() isn't executed. In the DOM tab of