July 1, 2009
It’s been a long time since I last posted. Since then I have been working on my first WPF contract. I have definately drank the cool aid, I love WPF (when MVVM is being used anyway).
One thing I haven’t been able to find any info on is how to close a window from XAML. I tried and tried and then gave up. Until now!
Having discovered the power of Attached Behaviours, I decided to write one that would close a window. All you need do then is create a data trigger that watches a CloseSignal on the ViewModel and sets the Close property to true.
public static class WindowCloseBehaviour
{
public static void SetClose(DependencyObject target, bool value)
{
target.SetValue(CloseProperty, value);
}
public static readonly DependencyProperty CloseProperty =
DependencyProperty.RegisterAttached(
“Close”,
typeof(bool),
typeof(WindowCloseBehaviour),
new UIPropertyMetadata(false, OnClose));
private static void OnClose(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is bool && ((bool)e.NewValue))
{
Window window = GetWindow(sender);
if (window != null)
window.Close();
}
}
private static Window GetWindow(DependencyObject sender)
{
Window window = null;
if (sender is Window)
window = (Window)sender;
if (window == null)
window = Window.GetWindow(sender);
return window;
}
}
and then in your XAML
<Style.Triggers>
<DataTrigger Binding=”{Binding CloseSignal}” Value=”true”>
<Setter Property=”Behaviours:WindowCloseBehaviour.Close” Value=”true” />
</DataTrigger>
</Style>
4 Comments |
C#, Things To Remember |
Permalink
Posted by adammills
May 4, 2008
Continuous Integration Factory (CI Factory) has just popped up onto my radar and looks fantastic.
Being currently on hiatus and looking to get into the London contracting scene I have been talking to expats about how much pain to expect. Build process comes up time and time again. I’ve heard of builds being manual and taking whole weekends!! So this looks to be a handy tool to have under your belt for getting CI setup quickly.
Leave a Comment » |
C#, Things To Remember | Tagged: Continuous Integration, Tools |
Permalink
Posted by adammills
May 4, 2008
Another awesome service that is getting traction is OpenID. OpenID is an online identity service where users sign up once and online applications use OpenID to authenticate.
Microsoft tried this before and failed, thankfully. This seems to be an independent foundation. And as long as it stays so, has my vote.
As a consumer this excites me. While our Toshiba R500 has made life easier by allowing us to connect most login details to my fingerprints. That solution only gets helps us so much (like whenever I’m around the laptop).
There are some obvious issues to overcome when dealing with centralised authentication. I don’t think any are daunting. And some like security are actually blessings in disguise. Like Open Source Software a central authentication system should be theoretically more secure. Instead of relying on the skill sets of a multitude of different teams implementing their own security systems for each application. A team of (hopefully) security experts are able to focus on the thing they do well. And let others focus on making their applications do what they are trying to do.
Convincing business to adopt it will be the real challenge.
Leave a Comment » |
Things To Remember | Tagged: Security |
Permalink
Posted by adammills
April 5, 2008
It’s been about 6 months since I left BluFreeway and took to a life of beaches and relaxation that ones honeymoon brings.
The call of coding had nagged me into installing VS 2008 on our lightweight travel laptop to stay afresh of developments in the .NET space. When a small error on my behalf (no prompts for bulk changes in Vista’s Photo Gallery!!) corrupted all the dates of our wedding photos that Kahlia had painstakingly rated, tagged and categorised.
Smiling smugly i said “No Problem!”, knowing all I had to do was whip up some code to copy the dates from the originals we had backed up. A few minutes later I had some code to do such a task. I even knew about EXIF and how to access it. How proud I was off myself knowing all about this graphics stuff! To my dismay the app whilst changing the metadata did nothing towards fixing the problem in Vista. Apparenlty my knowledge was out of date.
Enter Adobes brain child, XMP, a new era in metadata apparently. Thankfully .NET 3.5 has a great set of classes to handle this, WPF. It made the whole process really simple in the end. If only the documentation was as good.
Know it’s back to the sand and surf for awhile yet.
Leave a Comment » |
C# | Tagged: .NET 3.5, WPF, XMP |
Permalink
Posted by adammills
October 10, 2007
My time at CampaignMaster is coming to a close after 4.5 years. Working for PwC when IBM (Big Blue) bought them, I left just after the merger in March 2003. Four and a half years later I am leaving CampaignMaster after Bluefreeway acquired the company (to get married and travel)…. scary.
I though I’d look at the numbers:
- 1 subversion repositry
- 2 Server Locations
- 3 offices
- 4y 6m 21 days
- 9 Developers worked on CM (at different times)
- 14 blog posts (Huge!)
- 26 Major Releases
- 65 project files
- 3,000 Unit Tests
- 306,060 lines of code
- 10 000 000 + emails a month
I’m off for 4-6 months of travel and to get married. Our travels will be blogged about at http://www.chambills.com
Leave a Comment » |
Things To Remember |
Permalink
Posted by adammills