I have heard of this issue with WPF tab control. I think
if you google “WPF Tab Control Template Load”, you will probably
find a solution to tab control problem. We are not using tab control in
our software, we are faking it with stand-along buttons and grid to load
selected controls into. Not sure if this will address your load problem
though. You might need to have check your Provider.Data == null prior to
firing refresh in Loaded.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: ajj3085
[mailto:cslanet@lhotka.net]
Sent: Friday, November 21, 2008 4:05 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Problem with WPF PTracker sample?
Hi,
I've been building user controls based on the Wpf PTracker sample, which uses
the Loaded event to referesh the CslaDataProvider.
The problem is that Load and Unload will fire ANY time the control is loaded or
unloaded from the visual tree... this manifests itself in different ways.
One reason Unload / Load will refire is if the user changes their OS
theme. Another reason seems to be if you drop the user control into the
DocumentContent portion of the XamDockManager from Infragistics. As you
change tabs, the Unload event fires for any user control which is no longer
being displayed, and fires again when the user control is displayed.
This created a weird issue for me; I created a new part edit user control and
added it to a tab. I edited the part data and saved, and created another
new one without closing the original tab. When I was done, I clicked back
to the first tab... and the screen cleared and said I was working on a new
part.
Has anyone else hit this problem yet? I'm also looking for a reliable way
to do cleanup; my user control starts a DispatchTimer, and I'd like to shut it
off when the control is "closed."
Andy
I do not necessarily see sample as wrong or right, but more like
a training tool/sample code. I think, there is a steep learning curve
involved in moving to WPF from WinForms, and it is just a matter of doing it
and seeing what works. I do not follow PTracker exactly in my application,
but I did use it on occasion when I started with WPF. General principal still
works - single frame with multiple controls loaded into a placeholder in
main frame in response to user actions. All controls in my case user data
providers to get and update the data, and this is probably the only constant
for screen to screen. Like I mentioned, I do not use tab controls, but
this is not a major deal.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: ajj3085
[mailto:cslanet@lhotka.net]
Sent: Friday, November 21, 2008 4:37 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Problem with WPF PTracker sample?
Ya, it looks like this is pretty normal, but it caught me
off guard. I think this may have been asked before, but is it wrong to
use the UI samples as "best practice?" I'm still fairly new to
Wpf, so when building my Csla Wpf application, I'm tending to mimic what the
PTracker does.
I wouldn't necessarily look at the UI projects in ProjectTracker as "best practices". My goal with those projects is to demonstrate how to use data binding (and related techniques) to connect the UI to CSLA-style business objects.
Very clearly, there are many ways to build web, Windows and WPF interfaces. Many different design patterns, and entire UI frameworks (CAB, Prism, etc). I absolutely don't want to side-track CSLA into being a UI framework - those are big all by themselves, as is CSLA.
So I view the UI projects in ProjectTracker as illustrations of how data binding, and other key related concepts, work with business objects. You should look elsewhere for best practices and frameworks for UI creation.
Copyright (c) Marimer LLC