Dependency properties is one concept which i always marvel. As programmer / developer i always like the concept, as by just introducing DP, so many stuff now is so easy(Read Template programming in XAML). DP is called a BEAST (in Silverlight and WPF) for reasons of complexity involved in understanding them. Also, of course, because they are so powerful language paradigm. I sometimes do think DP did not actually got their due. I mean, so many efforts is gone into explaining Lambda expressions, LINQ,...
Although this post is called Scale Transform Behaviour you could use any transform / animation in its place. The purpose is to have a slider control in a menu be able to alter the scale of any number of controls within MVVM views. This behaviour allows you to add any Framework Elements to a list of attached controls by adding an attached property of GlobalScaleTransformBehaviour.IsScaled to your controls. Public Class GlobalScaleTransformBehaviour Private Shared sm_AttachedControls As List(Of FrameworkElement)...
You have probably heard me go on about Unity a couple of times: My.Unity.Resolve(Of Ninja) Unity and ASP.NET Creating a Data Access layer using Unity I have been using what is now unity since the good old days (sooo not true, WPF is the Windows Forms killer, and good riddance) of WindowsForms and CAB (Client Application Block), but now there is a lightweight alternative: Ninject. I decided on my latest project (a Wpf dashboard for HEAT ITSM) that I needed dependency injection. Whenever I start building...
A colleague of mine was having a bit of trouble getting drag and drop working in a way that fitted well with the MVVM pattern. This is really quite simple once you have a certain level of understanding of Patterns, but is a complete nightmare if you do not. One of the founding principals of MVVM is that you should never be writing code in your code behind, it should all be encapsulated away and be bindable in XAML to achieve the result. Anyone who has tackled drag and drip will have suddenly found...
I’ve just been porting a Windows Mobile (.Net CF) application over to the full Net Framework. I needed to provide a quick way of doing signature capture. I was pointed by a friend (thanks Ross), to look at hosting the WPF InkCanvas control on my Windows Forms, form. I just dropped a Panel (Panel1) on my form and used the following code - System.Windows.Controls.InkCanvas inkbox = null; public frmpleasesign() { InitializeComponent(); inkbox = new System.Windows.Controls.InkCanvas(); inkbox.Name =...
I have always been annoyed with the mechanics of the Team Foundation Server check-in policies. I understand the limitations, but having to have a specific policy installed on every developers computer before you can use it is slightly ridicules and practically unmanageable. Why is there not a way to have a single installation that allows you to select any policy you want and have it execute in the desired manor on every client, including web clients? I think it is. With the advent of the Dynamic...
A few days ago I wanted to monitor all routed events fired in my application. Because I am running an XBAP application inside a browser windows, Snoop wasn’t very helpful (it usually is). Because all routed events are basically the same, you can handle them all with one singe event handler. Using the EventManger it is possible to get all routed events and register a class handler for every one of them. The code below is a stripped down version of the code I’ve got implemented. When loaded, it gets...
We all reuse our windows controls out of the toolbox so why not our WPF user controls? The process is really the same. To show the steps involved let’s first write a simple WPF user control. After renaming the control and adding a WPF application project to my solution(to test with), my solution looks like this Since the functionality of the control is not important in this article, I just pasted in some animation code from msdn into my MyDemoControl.xaml file. <UserControl x:Class="MyDemoControl.MyDemoControl"...
I will be speaking at Iowa Code Camp this weekend. Greg Wilson, Bryan Sampica, and I are doing a series on WPF data binding. It should be a great time, so come on out!! These guys always put on a first class event. And the after party (the most important part of the weekend) is always awesome. (As for the cows, it’s an Iowa Code Camp thing. You kinda had to be there.) Technorati Tags: WPF,code camp...
In Visual Studio click on Debug –> Exceptions, and when the dialog box appears click “Add”. Fill it in as below: Be sure to check when “Thrown”. Now your code will break on the C# code where the error is thrown and you can find it more easily. Technorati Tags: WPF,XAML,Visual Studio...
Technorati Tags: WPF,MVVM Just posting a bunch of links to some really great articles on WPF. Pay special attention to the ones on the MVVM pattern. Very powerful stuff. Dan Crevier's Blog - DataModel-View-ViewModel Pattern Part One Introduction to Attached Behaviours in WPF Tales From The Smart Client - Attached Behaviour Pattern Sample Silverlight Behaviours A Guided Tour of WPF - 5 part series covering the basics Simplifying the TreeView by Using the ViewModel Pattern Using MVC to Unit Test WPF...
(J. Sawyer from Microsoft always gives a lively presentation. You won’t want to miss this one.) location: At Lamar Advertising Wednesday, February 18, 2009 5:45 PM - 8:15 PM Sponsored by: S3 Staffing Presenter(s): J. Sawyer J Sawyer is a Developer Evangelist for Microsoft's Developer and Platform Evangelist team, primarily covering south Texas and Louisiana. He was born and raised in a suburb of Baltimore, MD and discovered a passion for computing and developing software while working his way through...
This code example will show how to hide a listbox from the user when it doesn’t have any items. It involves binding the Visibility of the listbox to the Items.Count of the listbox. We run the Items.Count through a converter that will return a Visibility.Visible object if the Item.Count is not zero. Here is the converter class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Windows; namespace HideAListBox { public class...
Though some of you that were on the fence or have not year head about the MSDN Dev Con, are now more interested in coming out. It’s a tiny price compared to PDC and is coming to a city near you! A good group of local celebrities will be presenting along side proven Microsoft experts at the Orlando event. I will be in the attendance and around any community areas. And any social after event :) Bayer White (Jacksonville), Joe Homnick (Boca Raton), Christopher Bennage (Tallahassee), Rob Eisenberg (Tallahassee)...
Drew is my amazing nephew, and is the inspiration for this amazing project. Please take a look and let me know if you want to contribute in any way! iPhone development, Mac, xcode, WPF...
If, like me, you are interested in using all the new fangled controls produced by every man and his dog, you will probably have come across the Infragistics WPF control. My mission, that I stupidly accepted, was to update the TFS Sticky Buddy application with their XamRibbon and XamDockManager controls, and anything else I can stuff in there. The “anything else” I decided to use was the Composite WPF guidance. This is a newer WPF version of the Client Application Block (CAB) packages provided by...
If, like me, you like to have changeable resource files in your application. Wither it is for changing the Theme, or interchanging templates you will need to take special care when using the libraries. The new version of the TFS Sticky Buddy uses both! I am using the built in Infragistics theme system, and the first time you select a theme I am just adding a resource file that overrides the default: 1: Dim resourceDictionary As ResourceDictionary = ThemeManager.GetResourceSet(theme, ThemeManager.AllGroupingsLiteral)...
Using colors is a simple way make your application less boring. You can change the color of the selected and unselected item in a ListBox by using code like this: <Style TargetType="ListBoxItem"> <Style.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGreen"/> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightBlue"/> </Style.Resources> </Style> This style can be put in the resources of the ListBox...
Lets just say that it will be a while in development. I am trying to implement the Composite Application blocks for WPF from Microsoft in an attempt to make the application more modular. I will be updating and releasing under the v2.0 CTP version and I have uploaded the installation files. This is a ClickOnce application, so you will always have the latest version of the CTP. The current version CTP1 has only those changes to allow for the new Navigation and structure options, but More features are...
I will be working on some new features to the Sticky Buddy application. Improvements in the interface, along with a more modular structure and more diagram offering are in the mix. I have been working on some of the enhancements and their implementation in my other lesser known project TFS Heat ITSM… As you can see, a new look and feel for a new version, but this should allow me to implement a better modular design and separate out the individual bits and pieces. Head over to Codeplex and vote for...
There is a well-known issue with WPF RadioButton controls with data binding: when a radio button is unchecked the data binding is not undone. For example, suppose you have the following two radio buttons in the same group linked to a the "IsSuccess" (of type bool?) attribute of an object: <RadioButton Grid.Row="0" Grid.Column="0" GroupName="rbGroup" Margin="8,0,0,0" VerticalAlignment="Center" Content="Success" x:Name="rbSuccess" IsChecked="{Binding Path=IsSuccess, Mode=TwoWay, Converter={StaticResource...
Although I hate to quote that often, but, this one is totally worth it: Brad Abrams recently wrote a reference to this great "Evolving a .NET 3.5 Application" white paper, about the common scenario of migrating a .NEt 2.0 project to .NET 3.5. The white paper is available in PDF format here (direct link). About which I quote Brad's words: I reader recently forwarded me an interesting case study that covers a very common scenario: Porting a .NET Framework 2.0 based application to .NET Framework 3.5....
I was having a problem getting multi threading working with the ObservableCollection, and struggled to find a solution. So I asked my friend Google and after a while it directed me to Kevin's blog and specifically to his post on WPF Cross-Thread Collection Binding - Part 4 - The Grand Solution. This is a fantastic article, that provided me with the exact solution I was looking for, so I perused his other articles and found many tips on Multi-Threading.... One to watch... Technorati Tags: WPF,Threading,.NET...
Microsoft .NET framework 3.5 Service Pack 1 and Visual Studio 2008 Service Pack 1 now have public BETAs. The service pack of Visual Studio 2008 has really interesting stuff. Highlights I'm interested in are performance improvements in HTML editor, collection of JavaScript intellisense hotfixes plus new ones enabling better JavaScript intellisense for libraries like jQuery, JavaScript Code Formatting, ASP.NET Routing engine (the one used in ASP.NET MVC, it is actually developed as separate component),...
Let's say you have a custom WPF control called SearchTextBox. It has a textbox and a button labeled "search". Simple enough, you reuse it in your application when you want to provide search. Then one day, you decide you need this control needs to be bindable. So you expose a public property Text and map it to textSearch just like you would in WinForms. Well, that doesn't work, so you google around and stumble upon Dependency Properties and learn how to create your own (VS snippet shortcut propdb)...
I am looking around on the net for some classes for WPF, WCF, and WF plus any type of certification classes for the Microsoft Office SharePoint Server Tests. I want to try and pass at least one certification exam for MOSS by the middle of the year. I would also like to learn more information and start writing my own work flows. I know barely anything about WPF, except that it looks really nice. I bet that I could make some really snazzy webparts implementing this technology. I'm not the most awesome...
Imports System.DirectoryServices.AccountManagement In WPF development you can't just use the "My.User.Name" classes as it is not set by default. If you still want to use it you can "My.User.InitializeWithWindowsUser()" to have it setup, but there is a better way. If you are using Active Directory .Net 3.5 has provided a new way to access information... There is a new assembly called "System.DirectoryServices.AccountManagement" that encapsulates all of the logic for accessing security information...
In many ways, CAB and WPF have many similar functions. One area where there's overlap, and a little bit of pain is with WPF commands. If you're new to commands, here's a great blog post about them. The Microsoft Help for commands is here. Suppose the following: You have a search workspace that contains all of the logic for executing a search and displaying search results and a single search textbox. When a search result item is selected, you raise a cab event and then stuff happens. You want to go...
I had some trouble today getting the actual control that hosts data in a WPF listbox. The magic class is ListBox.ItemContainerGenerator used like this:MyStateObject current = this.myListBox.SelectedItem as MyStateObject; ListBoxItem lbi = this.myListBox.ItemContainerGenerator.ContainerFromItem(current) as ListBoxItem; lbi.Margin = new Thickness(10); Technorati tags: WPF, C#, ListBox, ItemContainerGenerator...
Today someone asked me, "How do you cause the double click event to fire in a tree view control using UI Automation"? Good question, and no, I don't have a good answer. Apparently, there isn't a good way to simulate this. In our case, we have a custom user control that is a popup that contains a WPF TreeView control. The user browses through the control until they find the node that they want and then they double click on the control to select the node, which is then raised as an event through the...
I've encountered a problem trying fix the WCF / WPF Visual Studio 2005 Integration components after I've installed Visual Studio 2008. Installing a VS 2008 will install .NET 3.0 SP1 and remove the installation of .NET 3.0. When trying to install the WCF / WPF Extension, installation display's a message Setup has detected that a prerequisite is missing. To use Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP you must have the .NET Framework 3.0 runtime installed....
I am sorry to tell you all that I am now (as of Friday past) off for the holiday period. With a little luck and some saved holidays I will not be back in the office until the 3rd January 2008 :) I will be in the office for damage control on the 31st, but apart from that I am a free man... Well, I have been looking after my daughter and playing my XBOX and generally faffing around with a lot of miscellaneous Christmas stuff online. I have still not got my Sharepoint 2007 development box working after...
A lot of times, I need to show or hide a textbox based the value of a checkbox. In WinForms 2.0. This was easy: myTextBox.Visible = myCheckBox.Checked; With the new Visibility Enum in WPF, this becomes a bit trickier. To accomplish this, you need to implement a converter that will accept a boolean value and return a visibility value. The converter I used is here: using System; using System.Collections.Generic; using System.Text; using System.Windows.Data; using System.Windows; namespace ParaPlan.Converters...
I think that any business application should select all the text in a TextBox when the user tabs into it. Your advanced users that take advantage of the tab key will appreciate it. In WinForms 2.0, the best way of accomplishing this was to create a new control that inherited from TextBox that implemented SelectAll functionality and use your new control instead of the normal TextBox. In WPF, this is much easier. In the App.xaml.cs, override the OnStartup method and use the EventManager.RegisterClassHandler...
In WPF, access keys are created like this:_Click Me! Pre-WPF was:&Click Me! Access keys in buttons work differently based on the type of control your text is rendered in. This code will only bring the keyboard focus to the button, it will not generate a click event: <Button Click="clickMeClick">_Click Me!</Button> When the user presses Alt - C on their keyboard, they expect the button to act as if it has been clicked, not just selected. To set keyboard focus and generate a click event,...
Intro to this series of posts. Some of the code I use for UI validation came from Paul Stovell, who is working on a WPF Element that acts like WinForms 2.0 ErrorProvider control. Paul's control didn't quite fit my needs, so I've tweaked a few things so I can provide visual validation in a generic fashion from my base class. All of our objects implement:Public Event InvalidProperty(string PropertyName, string ErrorMessage);Public Event Validated(object sender);Public bool IsValid; Our objects also...
Intro to this series of posts. There are a ton of posts out there about data binding with INotifyPropertyChanged objects in WPF, so I won't regurgitate what other people have already written. There is one point that I haven't see much clear documentation about that I would like to cover. Hosting data bound custom controls. Let's say we have a location control that is bound to a location object like so: <TextBox Text="{Binding Path=Address1}"/> <TextBox Text="{Binding Path=Address2}"/>...
The last month or so, I've been wallowing in Windows Presentation Foundation (WPF), trying to determine if it is the correct direction for our next version of our flagship software, ParaPlan. WPF is flashy and fun and bubbly, but there are not many examples of real world enterprise applications that are built around WPF. After much research, and significantly pushing back our deployment timeline, we decided to rebuild ParaPlan 4.0 using WPF for our UI. We were able to use our existing 2.0 UI framework...
I'm on the road for two weeks with ArcReady course of the next month - more on Josh Holmes Blog... Technorati tags: ArcReady, WPF, AJAX, Silverlight...
It was cool to meet Eric Burke who's the dev lead for the WPF version of the Yahoo Messenger app today at MIX - more on Josh Holmes Blog Technorati tags: MIX07, WPF...
This isn't new news, but cool nonetheless... LINQ: Language INtegrated Query... Finally set based operations become first class citizens! Here’s a snippet from Dan Fernandez’s post about LINQ static voidMain(string[] args) { string[] aBunchOfWords = {"One","Two", "Hello", "World", "Four", "Five"}; var result = from s in aBunchOfWords // query the string array where s.Length == 5 // for all words with length = 5 select s; // and return the string //PrintToConsole is an Extension method...