|
RNEELY, thanks for your reply.
I will try to reproduce this in a sample app after I finish moving most of the code out of the window class and into the MasterList class. For the time being the entire source for the application is available:
http://sourceforge.net/projects/subhub/[^]
In my testing so far, the closest I have come to narrowing down the problem is in the following code block involving a MessageBox:
private void Cmd_CloseDir_Executed(object sender, ExecutedRoutedEventArgs e)
{
SetUiAsBusy();
if (MessageBox.Show(this, "Do you really...", "Confirm close", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
DirTreeNode theDirTreeNodeToRemove = MainTree_GetSelectedDirTreeNode();
MasterList.RemoveDirTreeNodeAndChildren(theDirTreeNodeToRemove, true);
MasterList.FillUniqueLists();
MasterList.FileMatches.Clear();
}
SetUiAsFree();
}
When the method is run, if you select Yes from the MessageBox the problem will surface. If you select No then it will not. If I comment out the if (MessageBox.Show statement and just let the code run then the problem WILL NOT show up.
From what I can tell, the problem seems to show up when dialogs and background processes are involved.
I'll work to reproduce this in a sample this weekend.
|
|
|
|
|
Did you make the application via the "WPF Application" template in Visual Studio 2008? If not try doing that then porting your source code over to the new app and see it it works. What does SetUiAsBusy() do?
Sincerely,
-Ron
|
|
|
|
|
Yes, the app was made with the Wpf template.
Here's the SetUiAsBusy method:
private void SetUiAsBusy()
{
MasterList.UiIsFree = false;
NotifyPropertyChanged_All();
CommandManager.InvalidateRequerySuggested();
}
The SetUiAsFree method is the same except it is set to true. The UiIsFree variable is bound to the IsEnabled property of many UI elements.
In the method I posted earlier, MasterList.RemoveDirTreeNodeAndChildren(theDirTreeNodeToRemove, true); is where nearly everything happens. Several ObservableCollections are modified (safely as best as I can tell) that are bound to UI elements. No exceptions are getting swallowed and the VS output pane remains empty while the method runs.
|
|
|
|
|
Hi all,
at the moment I'm looking for a method to interact with the GUI components without using the mouse (i.e. the click on a button, or the drag and drop of a component in a Canvas).
I have an homebrew external devices that gives me just the coordinates of a point in the screen and the state of the click (down or up).
I know that I can control the mouse pointer using this device but I do not want to interfere with the mouse movements.
Could you help me?
Thanks in advance.
|
|
|
|
|
Dear all,
I am working on a 3D application using WPF. I am importing a 3D file in a viewport and i am doing some modification on that object( Move some of the object..)
I would like to make a sort of refresh of my figure to take in consideration the new changes( The equivalent of update in the windows Form). I am using the Thread.Sleep(1000);
to make the sleep .
Thanks you for your help.
Sondos
|
|
|
|
|
Hi,
I want to know whether i can load DWF/DXF/DWG files in my WPF application.I've searched a lot for loading these files.But,i didnt get any answer.Is that possible to import directly or should i convert the files into XAML format,since am working with WPF framework??I've even searched for XAML conversion of those files.But i could not find anything..Kindly suggest me..
Regards,
Priya
|
|
|
|
|
You are going to have to convert them I'm afraid - they are CAD files. However, you might be able to take advantage of something like this[^].
|
|
|
|
|
Have a look at CadLib[^], which supports displaying DWG and DXF files in WPF applications. There's a sample solution included in the evaluation version that demonstrates how to do it.
Wout
|
|
|
|
|
Hi All,
I need to make an application single instance, I've read and seen a few examples of doing this but none have really touched on WHERE to do this. In a WPF application with a normal App class inheriting from Application is this the best place to perform this check?
I'm looking at the Adam Nathan book which has a code sample, but putting this into the App class doesn't seem to work (this wont compile!):
public partial class App : Application
{
bool mutexIsNew;
using (System.Threading.Mutex m = new System.Threading.Mutex(true, "uniquename", out mutexIsNew))
{
if(mutexIsNew)
else
}
}
Looking at this MS example http://msdn.microsoft.com/en-us/library/ms771662.aspx[^] rather than using a mutex (which seems the best way) they import a visual basic namespace into a csharp app!!
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
You need to change the startup class so that it points to the one that has your Main method. This is accomplished by changing the Properties for your application in VS solution explorer. Look for the Startup Object list and choose your class. Note that you normally don't need to do this because VS automatically creates the Main based on the XAML app template. So, your main class would look something like this:
public class MyApp : Application
{
private static bool newMutex;
public static void Main()
{
using (Mutex m = new Mutex(true, "myApplication", out newMutex))
{
if (!mutexIsNew)
}
}
}
|
|
|
|
|
Hi Pete,
Thanks for this. I just popped off and made a StartUpObject.cs file and popped this code in there, then I changed the properties as you describe and the rest of my Presentation Layer UI stuff is blowing up. Popping this code into the App.xaml.cs is telling me that there is already a Main with the same parameter types. Should I be using the 'normal' App.xaml.cs or should I be creating a XAML file to go with my new StartUpObject.cs file?
EDIT:
Ok, I found some more info on the net and have done this but i'm now seeing binding errors so this isn't a good solution either:
Removed the StartUpUri="" from App.xaml and added this to my App.xaml.cs:
public partial class App : Application
{
private static bool mutexIsNew;
public App() : base()
{
using (Mutex m = new Mutex(true, "MyApp", out mutexIsNew))
{
if (mutexIsNew)
{
AppMainWindow mainwindow = new AppMainWindow();
mainwindow.Show();
}
else
{
App.Current.Shutdown();
}
}
}
}
Sorry for not getting this yet pete ...
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
modified on Friday, June 20, 2008 6:37 PM
|
|
|
|
|
If you can wait till Monday (when I'm back in the office), I can send you the startup code that we use - I'll drop it into a sample app for you.
|
|
|
|
|
That would be awesome Pete. Thank you!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer - here's a quick sample for you to try out:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Threading;
namespace SingleInstanceApp
{
public class SIApplication : Application
{
private static bool isNew;
[STAThread]
public static void Main()
{
using (Mutex m = new Mutex(true, "SIApplication.Mutex", out isNew))
{
if (isNew)
{
SIApplication app = new SIApplication();
app.InitializeComponent();
app.Run();
}
}
}
public void InitializeComponent()
{
this.StartupUri = new Uri("Window1.xaml", System.UriKind.Relative);
}
}
} Predictably, you need to set the startup object to point to this class. The trick is that you physically aren't going to create any other instances of the app because you have detected the state of the mutex before you create an instance of the app. BTW - you really need to use the StartupUri, I suspect this is where you've been getting your problems.
|
|
|
|
|
Thanks for this Pete, i'm just looking at this code now, I take it its ok to add this into the existing App.xaml.cs file rather than creating a completely new class.
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
No. This should be a new class. WPF automatically generates an App entry, so you need to get round this by creating your own Application class - set the startup object to point to this in your project references.
|
|
|
|
|
Works like an absolute charm!!! Thanks for this Pete!!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
|
Yes the app class is the place to do the check.
Try putting code inside the App:OnStartup() function.
<br />
public partial class App : Application<br />
{<br />
protected override void OnStartup(StartupEventArgs e)<br />
{<br />
bool mutexCreated;<br />
mutexRunOnce = new System.Threading.Mutex(<br />
true, "{someGUID}", out mutexCreated);<br />
if (!mutexCreated)<br />
{<br />
return;<br />
}<br />
<br />
base.OnStartup(e);<br />
}<br />
}<br />
Sincerely,
-Ron
|
|
|
|
|
Hello all,
For the past few days i've been trying to reproduce this sort of layout in wpf:
http://img170.imageshack.us/my.php?image=wp3hd5.png[^] But for the life of me I cant even get remotetly close to it. Basically the idea is to present a list of values as:
CountryName;CityName;Currency;Value;
C1;CITY1;E-U;0;
C1;CITY1;E-U;1;
C1;CITY1;U-E;0;
C1;CITY1;U-E;1;
C1;CITY1;U-E;3;
C1;CITY2;E-U;0;
C1;CITY2;E-U;1;
The organize them as shown in the screenshot grouped together by the first 3 columns. My first idea was to Create panels and nest sub controls into that (failed). Rendering grids within cells to get the items to grow accordingly to its children in code (failed). The last option will be to do it manually, as in redoing it with gdi as I have in the past, but wpf looks sooo nice it almost hurts not to try it.
I also took a look at some of Josh Smith's WPF tutorials on working with Treeviews and how to apply datatemplates on them, but hit another wall when trying to render the text vertically and fill the whole area covered by the children.
If someone has any ideas on how I can go about creating this sort of layout please let me know.
Thanks in advance.
/Rei
|
|
|
|
|
I'm not sure if you looked at this article or not, but I was able to get pretty close to your layout just by changing the grid from rows to columns and turning the StackPanel back to vertical orientation.
As far as rendering vertically, I would start by applying a layout transform of 90 or 270 degrees to the ContentPresenter. When you say fill the whole area, do you mean stretching the text to fill the whole area, or just stretch the background to fill the area? If you mean the latter, I would look for margins and paddings that may be causing the space between items.
|
|
|
|
|
I missed that article, you my friend just hit the nail right on the head!!! Thank you very much. And Josh, you're the man!
|
|
|
|
|
R A Roldan wrote: Josh, you're the man
Yep. May I recommend you read all of his WPF articles with time permitting Plenty of good to learn from him.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Good people,
I have a window that is laid out using a grid. The main part of the user interaction will take place in column 1, row 0. In order for the user to submit or get information, I basically have to load and remove items (e.g. a flowdocumentviewer, another grid containing a border, list box, and other child elements, etc...) into column 1, row 0 of the grid. The loading and unloading will be, of course, menu driven by the user.
My question is, how do I load those elements into the grid at the desired location, then discard them when I am finished? Also how do I make sure that they're not using up memory but have been deleted or discarded? If they are not in view; I don't need them.
I will need to do this programmatically in C#.
A final tangential question; how would you recommend I create these elements? I am using MS Expression Blend and normally I would create something in column1, row 0. However, since I need to create multiple elements to fully occupy that space, I am wondering if I should do it as a control?
Any thoughts you have would be greatly appreciated.
Thanks in advance.
BP
|
|
|
|
|
Definitely do it as a ContentControl - it will save you so much time in the long run. Secondly, you can set the position of something in your code using Grid.SetRow and Grid.SetColumn in a UIElement.
|
|
|
|