I am trying to use a WPF combo box to change a timer.
Currently, I have in an observable collection
15 mins
30 mins
45 mins.
1 hour.
If the user clicks 15 minutes, then a timer will start counting down.
But my problem is, once the user clicks 15 minutes, the combo box won't let me pick 15 minutes again to reset it.
I have to click on another item such as 30 minutes, then I can click 15 minutes.
This is using XAML, I was wondering if there is any quick fix to this.
Thanks!!
you could also handle the ComboBox DropDownClosed event to start your timer.
what event are you hooking onto to initiate your timer? i am guessing selecteditemchanged? if so then that will be the cause of the problem. try using the click event and get the selected item in your handler. if you post your code / xaml i will be able to give a better answer. you should be able to do what you are asking in xaml.
Related
In Windows Phone 7 Silverlight is there a way to be able to have a button that while I have it selected it calls on a callback function. Either that, or have to functions one for when the button is selected and one for when the button is released. Any ideas as how to do this?
Note that I have already looked at the the toolkit, and the gestures they provide do not include this.
Thanks!
you could look at this in-depth article on gestures:
http://windowsphonegeek.com/articles/WP7-GestureService-in-depth--key-concepts-and-API
specifically the Tap and hold gesture might work for you.
These events would be applicable:
•GestureBegin
The GestureBegin event.
public event EventHandler<GestureEventArgs> GestureBegin;
•GestureCompleted
The GestureCompleted event.
public event EventHandler<GestureEventArgs> GestureCompleted;
On MouseLeftButtonDown start a timer that will Tick until Button is released. Also, you have a control on timer tick Interval
Are you trying to create an action that is similar to the list item tilt effect. or like the video scrub bar. both of those operate when finger is down on the screen, then return to previous state when you remove your finger?
For future reference, and to save some future soul the frustration of why the heck MS didn't implement this in the first place as part of their SDK...
I ended up solving this problem by using ManipulationStarted to record the start time, and ManipulationEnd to record the end time of the gesture, and a separate thread to keep track of the ticks in between.
I have a form with 2 tabs. The first tab is boring, the second tab (unseen as default to the user) contains many comboboxes.
Using the FormLoad() event I populate a combobox on the second tab (with around 11,000 items/strings) on a background thread. The sql command to do this is also asynchronous.
Now, in theory this should mean that when the user finally gets round to clicking the second tab (whether that be in 10 seconds or 10 hours) they should be instantly presented with a nicely populated control - but there is ALWAYS a 4 second delay. I just don't get it! If all the heavy lifting is done via the background thread (the whole reason for using them in the first place!), why the heck is my application still slow and unresponsive when the user clicks that darn second tab??!!?!
*Bearing in mind you have to give the application a chance to fill the combo in the first place, plus I know when it's finished populating as the backgroundWorker1_RunWorkerComplete() method fires and sends a debug message to tell me all work has finished.*
Any help will be much appreciated....
11,000 is a lot! The work has been done to populate the comboBox items on the background thread, but the form still has to show all those items. This means the UI thread has to render a proportion of them (or all of them) to the UI (into memory) ready for scrolling; this is what is taking time.
I would suggest overriding the ComboBox control and handling the scroll event yourself. This way you can load a subset of the entire list sequentially when you need them (if that is possible in your case). This will prevent the four second delay you speak of.
I am working on Silverlight application and I want to make Image mousedouble click event,but there is no inbuilt mousedouble click in image control so I can do this..
Thanks...!!
The key to accomplishing this is to check for two things:
Measure the TimeSpan between two mouse clicks. Verify it is less than around 300 milliseconds.
Make certain the mouse has not moved more than a few pixels.
Try this http://www.michaelsnow.com/2010/05/10/silverlight-tip-of-the-day-17-double-click/
Regards.
The simplest way is to use a timer.
In the click event handler you have the following cases:
No timer. This is the first click, so start the timer and store the cursor location if necessary.
Timer running. This is potentially the second click. If the cursor hasn't moved then perform the single click action. Stop the timer.
The timer should stop itself after the double click interval (500 ms say) has expired.
I have a Silverlight 4 application that uses a DataGrid. This DataGrid is bound to a List of approximately 1,000 records. One of the columns on this grid is dynamic in the sense that it should update once every thirty seconds.
I have a DispatcherTimer setup that is triggered every 30 seconds. My question is, what is the best way for me to update the values of just that one column?
Thank you!
Make each dataitem representing the row implementing INotifyPropertyChanged, and raise the event when you update the column value. This should work by displayng the canges as soon as you update the variable.
I've got an SQL Query that runs when someone changes the Date on the DateTime Control on my Windows Form.
The Query is (currently) fired whenever the DateTime Control's ValueChanged property is fired.
This works poorly because:
If someone is trying to use the Control's scroll feature to go from January back to last September, the ValueChanged event fires once for each month (makes the GUI slow and makes unnecessary SQL calls).
If someone manually updates the date by typing the value into the text box, the ValueChanged property does not fire.
I can not use the Control's CloseUp property to solve #1 because then #2 would not fire.
A TextChanged property would be nice, but the DateTime Control does not expose one of those properties.
What is the best way to tell when my date has really been changed? (I'm not adding a timer that polls the form, either)
Development Environment: VS2008
Framework: 3.5
Language: C#
Target: Windows PC
(I'm not adding a timer that polls the form, either)
You exclude the one thing you should do to solve this problem. Then again, you wouldn't use a timer to poll the form, you start one in the DataChanged event handler. The Tick event handler disables the timer and runs the query. Make it a second or so. Add a button if you think that slows down the user too much.
A distant second choice could be an asynchronous query that you can cancel. Like SqlCommand.BeginExecuteXxxx(). Works well for the UI, not so well for the dbase server load.