Click here to Skip to main content
11,478,873 members (46,817 online)

Silverlight / WPF

 
AnswerRe: Converting WPF windows application to Web Application. Pin
db7uk26-Jan-13 14:17
memberdb7uk26-Jan-13 14:17 
QuestionGetting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Geert De Vylder21-Jan-13 5:51
memberGeert De Vylder21-Jan-13 5:51 
AnswerRe: Getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Mycroft Holmes21-Jan-13 19:36
memberMycroft Holmes21-Jan-13 19:36 
GeneralRe: Getting sqlexception "The multi-part identifier "System.Data.DataRowView" could not be bound." Pin
Geert De Vylder21-Jan-13 21:55
memberGeert De Vylder21-Jan-13 21:55 
QuestionBinding to attached property Pin
savbace20-Jan-13 22:22
membersavbace20-Jan-13 22:22 
QuestionRoot element is not valid for navigation Pin
Vuyiswa Maseko19-Jan-13 20:18
memberVuyiswa Maseko19-Jan-13 20:18 
AnswerRe: Root element is not valid for navigation Pin
Richard Deeming21-Jan-13 2:55
memberRichard Deeming21-Jan-13 2:55 
GeneralRe: Root element is not valid for navigation Pin
Vuyiswa Maseko21-Jan-13 5:49
memberVuyiswa Maseko21-Jan-13 5:49 
QuestionRandom Image with array Pin
Tikha17-Jan-13 12:23
memberTikha17-Jan-13 12:23 
AnswerRe: Random Image with array Pin
Pete O'Hanlon17-Jan-13 22:21
protectorPete O'Hanlon17-Jan-13 22:21 
AnswerRe: Random Image with array Pin
Abhinav S19-Jan-13 3:24
mvpAbhinav S19-Jan-13 3:24 
GeneralRe: Random Image with array Pin
Tikha21-Jan-13 18:09
memberTikha21-Jan-13 18:09 
GeneralRe: Random Image with array Pin
Dave Kreskowiak21-Jan-13 18:54
mvpDave Kreskowiak21-Jan-13 18:54 
QuestionDispatcherTimer Tick event not fired Pin
Praveen Raghuvanshi17-Jan-13 5:54
memberPraveen Raghuvanshi17-Jan-13 5:54 
Hi,

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.

http://stackoverflow.com/questions/7346663/how-to-show-a-waitcursor-when-the-wpf-application-is-busy-databinding[^]

http://stackoverflow.com/questions/3480966/display-hourglass-when-application-is-busy[^]

The usage is like this

public void WriteToFile(string fileName)
{
UiServices.SetBusyState();
_customFileWriter.WriteToFile(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.

MainWindow.xaml

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
 
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Menu Height="36" Name="menu1" Margin="12,0,439,197">
            <MenuItem Header="_File" Height="22" Name="menuitem1" Width="200" Margin="10, 10, 5, 5" HorizontalAlignment="Left" VerticalAlignment="Top" Background="Chocolate">
                <MenuItem Header="Save..."  Click="MenuItem_Click"/>
            </MenuItem>
        </Menu>
        <Canvas Height="156" HorizontalAlignment="Left" Margin="81,77,0,0" Name="canvas1" VerticalAlignment="Top" Width="304" Background="#FF945050">
            <Button Canvas.Left="128" Canvas.Top="49" Content="Button" Height="23" Name="button1" Width="75" Click="button1_Click" />
            <TextBox Canvas.Left="48" Canvas.Top="128" Height="23" Name="textBox1" Width="120" />
        </Canvas>
    </Grid>
</Window>

MainWindow.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
 
namespace WpfApplication1
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
		}
 
		private void 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;
			form.Show();
		}
 
		private void MenuItem_Click(object sender, RoutedEventArgs e)
		{
			string fileName = SaveFileDialog();
			UiServices.SetBusyState();
			System.Threading.Thread.Sleep(3000);
		}
 
		private string 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;
			}
			return filename;
		}
	}
 
	/// <summary>
	/// Sets the busy state on the application.
	/// Displays a wait cursor for long running tasks.
	/// </summary>
	public static class UiServices
	{
		/// <summary>
		/// A value indicating whether the UI is currently busy
		/// </summary>
		private static bool _isBusy;
 
		/// <summary>
		/// Sets the state as busy.
		/// </summary>
		public static void SetBusyState()
		{
			SetBusyState(true);
		}
 
		/// <summary>
		/// Sets the state to busy or not busy.
		/// </summary>
		/// <param name="busy">if set to <c>true</c> the application is now busy.</param>
		private static void SetBusyState(bool busy)
		{
			if (busy != _isBusy &&
				Application.Current != null &&
				Application.Current.Dispatcher != null)
			{
				_isBusy = busy;
				Mouse.OverrideCursor = busy ? Cursors.Wait : null;
 
				if (_isBusy)
				{
					new DispatcherTimer(TimeSpan.FromSeconds(0), DispatcherPriority.ApplicationIdle, DispatcherTimer_Tick, Application.Current.Dispatcher);
				}
			}
		}
 
		/// <summary>
		/// Handles the Tick event of the dispatcherTimer control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private static void DispatcherTimer_Tick(object sender, EventArgs e)
		{
			var dispatcherTimer = sender as DispatcherTimer;
			if (dispatcherTimer != null)
			{
				SetBusy(false);
				dispatcherTimer.Stop();
			}
		}		
	}
}

Thanks in advance!
AnswerRe: DispatcherTimer Tick event not fired Pin
Paulo Zemek23-Jan-13 7:28
memberPaulo Zemek23-Jan-13 7:28 
QuestionWhich way to load entity child collections? Pin
UCLAdam16-Jan-13 6:11
memberUCLAdam16-Jan-13 6:11 
QuestionWPF with Web Pin
Rishabh Kumar14-Jan-13 9:42
memberRishabh Kumar14-Jan-13 9:42 
AnswerRe: WPF with Web Pin
Abhishek Pant14-Jan-13 10:17
memberAbhishek Pant14-Jan-13 10:17 
AnswerRe: WPF with Web Pin
Abhinav S16-Jan-13 18:20
mvpAbhinav S16-Jan-13 18:20 
QuestionWPF - Bind IsEnabled To Method On VM Pin
Kevin Marois13-Jan-13 12:06
memberKevin Marois13-Jan-13 12:06 
AnswerRe: WPF - Bind IsEnabled To Method On VM Pin
Wayne Gaylard14-Jan-13 1:55
mentorWayne Gaylard14-Jan-13 1:55 
AnswerRe: WPF - Bind IsEnabled To Method On VM Pin
Richard Deeming14-Jan-13 3:13
memberRichard Deeming14-Jan-13 3:13 
GeneralRe: WPF - Bind IsEnabled To Method On VM Pin
Kevin Marois14-Jan-13 11:40
memberKevin Marois14-Jan-13 11:40 
GeneralRe: WPF - Bind IsEnabled To Method On VM Pin
Kevin Marois20-Jan-13 9:47
memberKevin Marois20-Jan-13 9:47 
QuestionWPF - Sync Combox [modified] Pin
Kevin Marois12-Jan-13 16:19
memberKevin Marois12-Jan-13 16:19 
AnswerRe: WPF - Sync Combox Pin
Mycroft Holmes13-Jan-13 1:50
memberMycroft Holmes13-Jan-13 1:50 
GeneralRe: WPF - Sync Combox Pin
Kevin Marois13-Jan-13 18:24
memberKevin Marois13-Jan-13 18:24 
GeneralRe: WPF - Sync Combox Pin
Mycroft Holmes14-Jan-13 1:11
memberMycroft Holmes14-Jan-13 1:11 
GeneralRe: WPF - Sync Combox Pin
Kevin Marois14-Jan-13 6:25
memberKevin Marois14-Jan-13 6:25 
GeneralRe: WPF - Sync Combox Pin
SledgeHammer0114-Jan-13 10:34
memberSledgeHammer0114-Jan-13 10:34 
GeneralRe: WPF - Sync Combox Pin
Kevin Marois23-Jan-13 18:41
memberKevin Marois23-Jan-13 18:41 
QuestionStyle From Resource File Not Being Applied Pin
Kevin Marois12-Jan-13 11:20
memberKevin Marois12-Jan-13 11:20 
AnswerRe: Style From Resource File Not Being Applied Pin
Richard MacCutchan13-Jan-13 0:44
mvpRichard MacCutchan13-Jan-13 0:44 
GeneralRe: Style From Resource File Not Being Applied Pin
Mycroft Holmes13-Jan-13 1:45
memberMycroft Holmes13-Jan-13 1:45 
GeneralRe: Style From Resource File Not Being Applied Pin
Richard MacCutchan13-Jan-13 2:24
mvpRichard MacCutchan13-Jan-13 2:24 
GeneralRe: Style From Resource File Not Being Applied Pin
Kevin Marois13-Jan-13 11:58
memberKevin Marois13-Jan-13 11:58 
QuestionRoutedEvent vs AttachedEvent - Syntax difference only? Confused [modified] Pin
devvvy9-Jan-13 21:05
memberdevvvy9-Jan-13 21:05 
QuestionHow to play an Audio File After another has Finished in WPF MediaElement Pin
Vuyiswa Maseko4-Jan-13 4:58
memberVuyiswa Maseko4-Jan-13 4:58 
AnswerRe: How to play an Audio File After another has Finished in WPF MediaElement Pin
Pete O'Hanlon4-Jan-13 5:13
protectorPete O'Hanlon4-Jan-13 5:13 
GeneralRe: How to play an Audio File After another has Finished in WPF MediaElement Pin
Vuyiswa Maseko4-Jan-13 7:08
memberVuyiswa Maseko4-Jan-13 7:08 
QuestionWPF tutorial book website pdf Pin
frazzle-me1-Jan-13 11:44
memberfrazzle-me1-Jan-13 11:44 
AnswerRe: WPF tutorial book website pdf Pin
Richard MacCutchan1-Jan-13 23:31
mvpRichard MacCutchan1-Jan-13 23:31 
GeneralRe: WPF tutorial book website pdf Pin
frazzle-me2-Jan-13 2:47
memberfrazzle-me2-Jan-13 2:47 
GeneralRe: WPF tutorial book website pdf Pin
Pete O'Hanlon2-Jan-13 6:48
protectorPete O'Hanlon2-Jan-13 6:48 
GeneralRe: WPF tutorial book website pdf Pin
Richard MacCutchan2-Jan-13 7:09
mvpRichard MacCutchan2-Jan-13 7:09 
GeneralRe: WPF tutorial book website pdf Pin
Pete O'Hanlon2-Jan-13 7:10
protectorPete O'Hanlon2-Jan-13 7:10 
AnswerRe: WPF tutorial book website pdf Pin
Abhinav S2-Jan-13 3:21
mvpAbhinav S2-Jan-13 3:21 
GeneralRe: WPF tutorial book website pdf Pin
frazzle-me2-Jan-13 8:08
memberfrazzle-me2-Jan-13 8:08 
AnswerRe: WPF tutorial book website pdf Pin
Fernando E. Braz2-Jan-13 6:15
memberFernando E. Braz2-Jan-13 6:15 
GeneralRe: WPF tutorial book website pdf Pin
frazzle-me2-Jan-13 8:07
memberfrazzle-me2-Jan-13 8:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 22 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid