I am working on a WPF application. The application uses Infragistics controls such as Ribbon Controls and XamDockManager. It has a File Menu wherein I have provided a Save menu item to save the items on the canvas to a file. On click of Save button, Save Dialog opens to provide the File name and file is saved at the defined location.
The saving process is quite time consuming and in order to show something to the user, I have used the WaitCursor.
I have used a class similar to the one mentioned(UiServices.ShowWaitCursor) in the below thread.
public void WriteToFile(string fileName)
This works fine, if we just save the things on the canvas into a file. However, if fails in the below scenario.
The application has a canvas where I display some UI elements. On double click of the UI element, we launch a Windows form in the Infragistic ContentPane.
We have a modeless dialog opened and perform File -> Save and provide a file name, the cursor stays indefinitely. It goes only once we click on the Canvas. The DispatcherTimer_Tick is fired only when we click on the Canvas which resets the cursor.
The DispatcherPriority is ApplicationIdle.
Another observation is, this happens only when we open the Save dialog through the File -> Save. It works fine if we open the Save dialog through Ctrl + S key combinations.
Is there a way I can debug the non firing of DispatcherTimer.Tick event or any other way to handle this?
I created a simple WPF application and it works fine in that.
///<summary>/// Interaction logic for MainWindow.xaml
///</summary>publicpartialclass MainWindow : Window
privatevoid button1_Click(object sender, RoutedEventArgs e)
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
form.Height = 200;
form.Width = 400;
form.TopMost = true;
privatevoid MenuItem_Click(object sender, RoutedEventArgs e)
string fileName = SaveFileDialog();
// Create SaveFileDialog
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
// Display SaveFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
string filename = string.Empty;
// Get the selected file name
if (result == true)
// Open document
filename = dlg.FileName;
///<summary>/// Sets the busy state on the application.
/// Displays a wait cursor for long running tasks.
///<summary>/// A value indicating whether the UI is currently busy
///<summary>/// Sets the state as busy.
///<summary>/// Sets the state to busy or not busy.
///</summary>///<paramname="busy">if set to <c>true</c> the application is now busy.</param>privatestaticvoid SetBusyState(bool busy)
if (busy != _isBusy &&
Application.Current != null &&
Application.Current.Dispatcher != null)
_isBusy = busy;
Mouse.OverrideCursor = busy ? Cursors.Wait : null;
new DispatcherTimer(TimeSpan.FromSeconds(0), DispatcherPriority.ApplicationIdle, DispatcherTimer_Tick, Application.Current.Dispatcher);
///<summary>/// Handles the Tick event of the dispatcherTimer control.
///</summary>///<paramname="sender">The source of the event.</param>///<paramname="e">The <seecref="System.EventArgs"/> instance containing the event data.</param>privatestaticvoid DispatcherTimer_Tick(object sender, EventArgs e)
var dispatcherTimer = sender as DispatcherTimer;
if (dispatcherTimer != null)
I can't execute your code (I don't have those libraries you use), but can you use another priority?
I don't know... maybe you have an animation or similar that is never really letting the application become idle.
Note: Seeing your code, you don't need to use a DispatcherTimer. It is enough to do a Dispatcher.BeginInvoke to call your delegate. This will also guarantee that it will execute only once, as soon as all the messages (including the actual one) are processed. In fact, I think your problem is that you never started your timer.
Hopefully this will be a quick question to answer, but personally I'm not sure which way to go.
Firstly I'm using SL5, MVVM, MEF, EF. I have a person entity - the person entity has a collection of account entities, address entities and order entities.
In my view I am displaying a list of the people on the left with the corresponding lists on the right (accounts, addresses, orders). When the person is changed in the list I obviously want the lists on the right to update.
Obviously it would be inefficient to just include the lists in the domain service query using the .Include() operation as it will return ALL the people with ALL the related list entities. This is where my dilemma is - when I change the person do I either:
Load each of these lists separately, each with their own completed events where I populate the view lists. Which is basically three extra calls to the DB.
2. Call a different GetPeople query in the domain service where I pass in the current person ID and use the .Include() operation to include accounts, address and orders, but filter by the passed in PersonID. (i.e. return this.ObjectContext.People.Include("Accounts").Include("Addresses").Include("Orders").Where(p=>p.ID == PersonID);)
Can I integrate WPF application in web application??
I am working in a website, in this I want to integrate a small WPF application. Can i do this?? for eg... I wanna open login/signin popUp ("which is created in WPF") in my web application to enter the user in main page.
or we can say that in any tutorial webpage, I want to insert demo application of WPF application.
If it is possible please let me know, how i can do this.
I'm working on an WPF MVVM application. The data entry screen has to have all it's fields disabled until the user clicks "Add" or "Edit", and also the fields cannot become enabled if the user does not have rights to that field.
So, I would like to bind all IsEnabled properties in the XAML to a single method on the ViewModel. I would need to pass in a string value which is the 'key' of the field. Then in the VM would use the key to check the rights. The method would be something like
publicbool CanEnableField(string Key)
// if the form is in Add or Edit Mode, and the user has rights to the field, then
// return true, else false
A converter would probably not work because that class won't know about the VM and the form's mode (Add/Edit).
I could bind each field's IsEnabled to individual properties on the VM and handle all this in the getter, but that would be a lot of properties in the VM.
The best way is to have a bool Property in your VM, to which you caan bind the IsEnabled property of the relevant controls like this:-
publicbool CanEnableField(string Key)
// if the form is in Add or Edit Mode, and the user has rights to the field, then EnableControls = true
if (enableControls != value)
enableControls = value;
I have a combo box bound to an ObservableCollection<classmodel>. The entity passed into the view has an instance of a ClassModel. I want to select the item in the combo which matches the entite's ClassModel.
So far im lookping over the ObservableCollection to find the item:
foreach (var jobClass in Classes)
if (jobClass.Id == JobRevision.JobClass.Id)
SelectedClass = jobClass;
From my deep knowledge of all things xaml (insert sarcasm smiley): When you create a style.xaml file that contains the style for DataEnteryTextBlockForeColorBrush. you can reference it via the app.xaml (Silverlight) and it becomes a static resource available to all views. You can also create the style in the view's xaml as a resource (grid.resource/usercontrol.resouce etc) and it becomes a static resource usable by that view only.
Hang on you answer more of these than I do!
Never underestimate the power of human stupidity
Following example I managed to get fire both a RoutedEvent and an AttachedEvent from "GrandChild" and have them handled in "MainWindow" two levels up - but I am now confused what's difference between the two? Except how they are declared in "GrandChild". I want to add that both use "RegisterRoutedEvent" but RoutedEvent has a CLR wrapper
Now i tried to put it a Thread Sleep between, it work once after that the Second mp3 plays after the first one. So i want to call the same function twice to play different mp3's but i want one to wait for another to finish playing before playing, i hoped for a "isPlaying" Property to determine if the element was playing. Does anyone have a solution.
//Function to Play a Video
privatevoid PlayAudio(string Fruit)
VideoPlayer.Source = new Uri(@"D:\Articles\How to identify Players in Kinect\IdentifyPlayers\WpfApplication1\WpfApplication1\Voices\" + Fruit + ".mp3", UriKind.Absolute);
VideoPlayer.LoadedBehavior = MediaState.Manual;