<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1992668869069529692</id><updated>2011-11-27T17:30:03.313-06:00</updated><category term='Thoughts'/><category term='MEF'/><category term='WinForms'/><category term='WPF'/><title type='text'>.NET Dev Gig</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-4493240179906364946</id><published>2010-07-27T22:10:00.002-05:00</published><updated>2010-07-28T09:24:41.378-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF TimePicker</title><content type='html'>So the WPF project I am working on requires a TimePicker. Nothing out of the box, or in the WPF Toolkit. The controls you can buy were workable, but not what I was looking for. Plus I have coded all of the project using open-source controls, and controls I coded myself.  So why buy something now?  I was about to start coding up everything from scratch until I ran across the &lt;b&gt;FREE&lt;/b&gt; &lt;a href="http://www.viblend.com/downloads.aspx"&gt;VIBlend&lt;/a&gt; Input Controls for WPF. VIBlends DateTimeEditor was a good start, but not the usability I was looking for. Especially since I was going to use the WPF DatePicker and TimePicker together, and bind the same DateTime property to both.   &lt;br /&gt;
&lt;br /&gt;
The final implementation is not the prettiest, but I had to work around the constraints of the VIBlend control, which Reflector helped me figure out. They do have documentation, but it mostly gives you the different formatting options you can use, etc. Plus why read documentation when you have Reflector :). Anyways, after about an hour from thought to finish, here is my TimePicker control used with the WPF DatePicker.   &lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;&lt;a href="http://lh3.ggpht.com/_d0ZESGyylkc/TE-flW_iC6I/AAAAAAAAADU/TSwuygIMonA/s1600-h/TimePicker%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="TimePicker" border="0" alt="TimePicker" src="http://lh6.ggpht.com/_d0ZESGyylkc/TE-fllc0mmI/AAAAAAAAADY/KpW54gf4fL4/TimePicker_thumb.png?imgmax=800" width="244" height="132" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The TimePicker has a “Now” button to set the Time to the current time. Also the “Up” and “Down” arrows add and subtract hours by default, unless the minute or AM/PM text is selected. The intent is to make it as easy for the user as possible.   &lt;br /&gt;
So here is the code if you want this TimePicker for your project.   &lt;br /&gt;
&lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-df3a504ac854b960.office.live.com/embedicon.aspx/.Public/WpfControlTimePicker.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;br /&gt;
&lt;br /&gt;
Enjoy...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-4493240179906364946?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/4493240179906364946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2010/07/wpf-timepicker.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/4493240179906364946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/4493240179906364946'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2010/07/wpf-timepicker.html' title='WPF TimePicker'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_d0ZESGyylkc/TE-fllc0mmI/AAAAAAAAADY/KpW54gf4fL4/s72-c/TimePicker_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-2984794140313687003</id><published>2010-07-25T07:41:00.006-05:00</published><updated>2010-07-26T13:23:55.564-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Thoughts'/><title type='text'>Thoughts around Requirements Driven Development</title><content type='html'>&lt;p&gt;So I have been thinking about Test Driven Development (TDD) more than usual lately. I am mainly focusing on the concept of unit tests around every method to get 100% code coverage. I know that TDD is more than just this, but it seems that is where I see the most focus around the concept of TDD.&lt;/p&gt;&lt;p&gt;The reality I live in cannot get that type of buy-in. The time and budget constraints will not allow for it, because projects have a project management focus, where success is measured on meeting the time and budget constraints, and not on the maintenance and support impact (quality) of what is about to be delivered (SDLC vs. ALM focus). Of course if something is not “correct”, then developers get beat up because they are responsible for “code quality”.&lt;/p&gt;&lt;p&gt;The area where I have had the most significant software failure was around requirements. Everything ran great and past the tests, but a significant requirement was missed that caused the project to be a failure. So the question is... Do requirements drive code quality, and should our testing be around meeting those requirements?  If you think about it, everything you code is done to meet some requirement. Either documented or implied by you. Also nothing is an island into itself; it is part of a collective of routines, systems, etc. to meet a requirement.&lt;/p&gt;&lt;p&gt;I am sure you are thinking, how is this possible because we never get good requirements. Good point. Most organizations I have worked for, the person who is responsible for “time and budget” is the one documenting the requirements that developers have to live up to. Yikes! &lt;/p&gt;&lt;p&gt;As I have been getting training (yes there is training out there), and practicing as an architect, I am starting to lean towards the thinking that architects should be responsible for the final functional and technical requirements that get delivered to the development team (that statement implies that an architect should be involved in every project, which is another topic all together). Code that gets delivered should be wrapped in one or more test cases that demonstrate that a specific requirement is met.&amp;#160; TFS 2010 has the ability to do this (shameless plug for a Microsoft product).&amp;#160; The challenge is around constructing the test cases in a way that provides a result to validate that the combination of methods and systems meet the requirement. Both technical and functional requirements are in this mix of requirements. For example, you might have code that meets a specific technical requirement, but not a functional requirement.&lt;/p&gt;&lt;p&gt;I am not saying that you should not create unit tests on methods that will catch the occasional logic bomb or capture a fix that broke something else (regression test).&amp;#160; All I am saying is that if we cannot demonstrate how our code meets a requirement, then why are you writing that code in the first place?  Let’s consider the stakeholder perspective of “code quality”.&amp;#160; Does the application meet my requirements?&amp;#160; If it does, then the code is “quality code” that gives them exactly what they paid for.&lt;/p&gt;&lt;p&gt;Again this is not the answer to everything, or something that I am able to be rigid about practicing today.&amp;#160; I am also not saying that this is the answer to all code quality issues.&amp;#160; I am proposing that a big part of code quality starts and ends with good requirements (Requirements Driven Development).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-2984794140313687003?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/2984794140313687003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2010/07/thoughts-around-requirements-driven.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/2984794140313687003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/2984794140313687003'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2010/07/thoughts-around-requirements-driven.html' title='Thoughts around Requirements Driven Development'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-3607299102059307316</id><published>2010-07-10T22:20:00.001-05:00</published><updated>2010-07-10T22:28:09.547-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF DatePicker DateTime Validation</title><content type='html'>&lt;p&gt;At first blush validating a DatePicker SelectedDate bound to a DateTime property seems pretty straight forward.&amp;#160; But I immediately ran into problems when I cleared the DatePicker textbox.&amp;#160; It blew up the application with a DependencyProperty.UnsetValue error.&amp;#160; After doing some research it seems that I had two issues.&amp;#160; &lt;/p&gt;  &lt;h5&gt;Error Template&lt;/h5&gt;  &lt;p&gt;One is that if you set the ErrorTemplate as part of a default style it had problems with this scenario.&amp;#160; I set the Validation.ErrorTemplate directly with a ControlTemplate that contained my error display using …&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:6bd29151-f48c-4ada-9921-a38f67a04bdc" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: xml;"&gt; &amp;lt;!-- Error Adorner--&amp;gt;
        &amp;lt;ControlTemplate x:Key="InputErrorTemplate"&amp;gt;
            &amp;lt;DockPanel&amp;gt;
                &amp;lt;Ellipse 
                  DockPanel.Dock="Right" 
                  Margin="2,0"
                  ToolTip="{Binding ElementName=errorAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
                  Width="10" Height="10"   
                  &amp;gt;
                    &amp;lt;Ellipse.Fill&amp;gt;
                        &amp;lt;LinearGradientBrush&amp;gt;
                            &amp;lt;GradientStop Color="#11FF1111" Offset="0" /&amp;gt;
                            &amp;lt;GradientStop Color="#FFFF0000" Offset="1" /&amp;gt;
                        &amp;lt;/LinearGradientBrush&amp;gt;
                    &amp;lt;/Ellipse.Fill&amp;gt;
                &amp;lt;/Ellipse&amp;gt;
                &amp;lt;AdornedElementPlaceholder x:Name="errorAdorner" /&amp;gt;
            &amp;lt;/DockPanel&amp;gt;
        &amp;lt;/ControlTemplate&amp;gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h5&gt;Converter&lt;/h5&gt;

&lt;p&gt;Next I had to add a Converter to change the value back from null to 01.01.0001, which is the default DateTime value.&amp;#160; Any incoming DateTime values to the DatePicker control of 01.01.0001 are subsequently changed to String.Empty to show that a date has not been selected.&amp;#160; Here is an example of the following changes to the DatePicker control.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="brush: xml;"&gt;

&amp;lt;DatePicker Validation.ErrorTemplate="{StaticResource InputErrorTemplate}" SelectedDate="{Binding Item.CurrentDate, ValidatesOnDataErrors=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DateTimeConverter}}" /&amp;gt;

&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Of course this could have been solved by a nullable DateTime (DateTime?).&amp;#160; The problem with nullable types is that they are ValueTypes, meaning that they cannot be boxed and unboxed.&amp;#160; So if you are using an interface to expose a Model object from a ViewModel object, your DateTime value does not come through.&amp;#160; &lt;/p&gt;

&lt;h5&gt;Validation&lt;/h5&gt;

&lt;p&gt;The last part is validation of the DateTime property to make sure and let the user know if an invalid date is entered in the DatePicker.&amp;#160; The Converter we put in place makes sure that a DateTime value always gets sent to the SelectedDate bound property.&amp;#160; Which does not help us notify the user that an invalid date was entered.&amp;#160; So the last piece is a custom DateTime Validation Attribute.&amp;#160; &lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:fceae39b-83ac-46c5-822e-fa418718d22d" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;"&gt;public class DateTimeAttribute : ValidationAttribute
    {
        public DateTimeAttribute() : base(() =&amp;gt; "Invalid date") { }
        public DateTimeAttribute(string errorMessage) : base(() =&amp;gt; errorMessage) { }
        public override bool IsValid(object value)
        {
            //check for null
            if (value == null)
                return true;

            //check date
            if (!(value is DateTime))
            {
                //check string
                string val = value as String;
                if (String.IsNullOrEmpty(val))
                    return true;

                DateTime dt;
                bool isValid = DateTime.TryParse(val, out dt);
                if (isValid &amp;amp;&amp;amp; dt.Year.Equals(0001))
                    return false;
                else
                    return isValid;
            }
            else if (((DateTime)value).Year.Equals(0001))
                return false;
            else
                return true;

        }&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I am exploring using DataAnnotations to decorate properties with validations and other interesting metadata.&amp;#160; Unfortunately WPF does not have the same level of DataAnnotation support that you get with Silverlight using the Silverlight toolkit.&amp;#160; That simplifies keeping the Display Name for the Label the same as the Label on the Error string if you are doing validation on annotations.&amp;#160; I will explore this in another posting of a WPF implementation that comes close to what Silverlight offers.&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:27c2aa32-5c52-48b8-9066-45f6655aea5d" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;"&gt; private DateTime _currentDate;

        [Required(ErrorMessage = "Is required")]
        [DateTime(ErrorMessage = "Invalid Date")]
        [Display(Name = "Current Date")]
        public DateTime CurrentDate
        {
            get
            {
                return this._currentDate;
            }
            set
            {
                if (this._currentDate != value)
                {
                    this._currentDate = value;
                    this.OnPropertyChanged("CurrentDate");
                }
            }
        }&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Well there you have it.&amp;#160; To me it seems like a lot of code to validate a Date in the DatePicker control.&amp;#160; Time and budget constraints are going to force me to make due with what I have done thus far.&amp;#160; I would be interested in hearing what others are doing.&lt;/p&gt;

&lt;p&gt;Here is a screen shot of the sample form that also contains Label DataAnnotation behavior similar to Silverlight toolkit.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_d0ZESGyylkc/TDk4dKY3UuI/AAAAAAAAADM/ZN-6W-xWwjk/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_d0ZESGyylkc/TDk4dpjNKJI/AAAAAAAAADQ/xxqZzdzq2GY/image_thumb%5B1%5D.png?imgmax=800" width="326" height="248" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Here is the sample code.&lt;/p&gt;
&lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-df3a504ac854b960.office.live.com/embedicon.aspx/.Public/Samples.Validation.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;

&lt;p&gt;Enjoy…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-3607299102059307316?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/3607299102059307316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2010/07/wpf-datepicker-datetime-validation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/3607299102059307316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/3607299102059307316'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2010/07/wpf-datepicker-datetime-validation.html' title='WPF DatePicker DateTime Validation'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_d0ZESGyylkc/TDk4dpjNKJI/AAAAAAAAADQ/xxqZzdzq2GY/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-2601993794904061450</id><published>2010-07-04T01:26:00.003-05:00</published><updated>2010-07-04T02:35:17.854-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF Highlight AutoComplete Textbox</title><content type='html'>The February 2010 release of the &lt;a href="http://wpf.codeplex.com/"&gt;WPF Toolkit&lt;/a&gt; finally brings with it the AutoCompleteBox.&amp;nbsp; A much needed control for business apps.&amp;nbsp; Of course the AutoCompleteBox is not enough for today’s users.&amp;nbsp; Everyone wants more of a suggestion box that works like Bing search, by providing suggestions and highlighting text.&amp;nbsp; Jeff Wilcox from Microsoft wrote a great blog on how to &lt;a href="http://www.jeff.wilcox.name/2008/11/highlighting-autocompletebox/"&gt;implement a highlight textbox&lt;/a&gt; using the Silverlight AutoCompleteBox.&amp;nbsp; Basically the implementation is the same except that all of the styles are contained inside a custom HighlightTextBoxControl.&amp;nbsp; I also added some methods to interact with a database call which is the SearchByToken delegate.&lt;br /&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:503d34da-4a93-42ba-9a9f-9070ef1a473e" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;pre class="brush: csharp;"&gt;public void Initialize(SearchByToken searchByToken, Action advancedCommand)
        {
            this.searchByToken = searchByToken;
            this.AdvancedCommand = new RelayCommand(() =&amp;gt;
                {
                    advancedCommand.Invoke();
                });
        }

        public delegate List&amp;lt;IViewItem&amp;gt; SearchByToken(string searchToken, out int totalCount);
        
        private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
        {
            AutoCompleteBox autoComplete = (AutoCompleteBox)sender;

            // Allow us to wait for the response
            e.Cancel = true;

            if (this.searchByToken == null)
                throw new ArgumentException("You must set the SearchByTokenDelegate");

            searchByToken.BeginInvoke(this.highlightTextBox.SearchText, out totalCount, new AsyncCallback(SearchCompleted), searchByToken);
        }&lt;/pre&gt;&lt;/div&gt;The resulting popup highlights the matching text, as well as shows the total count of matching records and the text used for matching.&amp;nbsp; In the final implementation I limited the database query to only show the top 25 so that I don’t return hundreds of matching records after the first two characters are typed, and locking up the UI.&amp;nbsp; I have also included an Advanced find button as part of the template.&amp;nbsp; Here is a screen shot of the result.&lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/_d0ZESGyylkc/TDApmbIw3WI/AAAAAAAAADE/IjK443ZOo20/s1600-h/HighlightTextBox%5B3%5D.png"&gt;&lt;img alt="HighlightTextBox" border="0" height="244" src="http://lh5.ggpht.com/_d0ZESGyylkc/TDApmrmCJ_I/AAAAAAAAADI/sCUoBP5uV_s/HighlightTextBox_thumb%5B1%5D.png?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="HighlightTextBox" width="373" /&gt;&lt;/a&gt;&lt;br /&gt;
I have included the sample project below.&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-df3a504ac854b960.office.live.com/embedicon.aspx/.Public/HighlightTextBox.zip" style="background-color: #fcfcfc; height: 115px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 98px;" title="Preview"&gt;&lt;/iframe&gt;&lt;br /&gt;
Enjoy…&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-2601993794904061450?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/2601993794904061450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2010/07/wpf-highlight-autocomplete-textbox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/2601993794904061450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/2601993794904061450'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2010/07/wpf-highlight-autocomplete-textbox.html' title='WPF Highlight AutoComplete Textbox'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_d0ZESGyylkc/TDApmrmCJ_I/AAAAAAAAADI/sCUoBP5uV_s/s72-c/HighlightTextBox_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-6898493498050721719</id><published>2010-04-28T00:19:00.004-05:00</published><updated>2010-04-28T00:32:46.497-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF Button Label with CheckBox</title><content type='html'>I was recently working with some checkboxes, and was unhappy with the area available to click the checkbox. I achieved what I was looking for by applying a ControlTemplate to a ToggleButton. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_d0ZESGyylkc/S9fHL0Qy-xI/AAAAAAAAAC4/HU-vxQZjEZU/s1600/ButtonLabelWithCheckBox.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="175" src="http://2.bp.blogspot.com/_d0ZESGyylkc/S9fHL0Qy-xI/AAAAAAAAAC4/HU-vxQZjEZU/s320/ButtonLabelWithCheckBox.png" tt="true" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
I have include the code below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-df3a504ac854b960.skydrive.live.com/embedicon.aspx/.Public/ButtonLabelWithCheckBox.zip" style="background-color: #fcfcfc; height: 115px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 98px;" title="Preview"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enjoy...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-6898493498050721719?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/6898493498050721719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2010/04/wpf-button-label-with-checkbox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/6898493498050721719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/6898493498050721719'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2010/04/wpf-button-label-with-checkbox.html' title='WPF Button Label with CheckBox'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_d0ZESGyylkc/S9fHL0Qy-xI/AAAAAAAAAC4/HU-vxQZjEZU/s72-c/ButtonLabelWithCheckBox.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-4409895089698896180</id><published>2010-02-28T23:53:00.005-06:00</published><updated>2010-03-03T07:46:54.931-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='MEF'/><title type='text'>MEF (Factory Pattern Example)</title><content type='html'>Managed Extensibility Framework (MEF) is new library in .NET 4.0. What is interesting about MEF is that it allows you to create Composable Parts that can be Exported and Imported. Imported Parts can provide MetaData that can be used to evaluate the Part and make a decision if you should instantiate the object or not. This opens up a lot of interesting possibilities and scenarios. The first in my series shows how you could implement a Factory Pattern with very little code. For example each concrete class is Exported with the IState interface. &lt;pre class="brush: csharp;"&gt;[Export(typeof(IState)), StateMetadata(&amp;quot;Texas&amp;quot;)]
public class Texas : IState
&lt;/pre&gt;The Export can be provided with MetaData that tells you information about the concrete class such as the name of the state in the example above.  &lt;pre class="brush: csharp;"&gt;public interface StateMetadata
{
    string Name { get; }
}

[MetadataAttribute]
public class StateMetadataAttribute : Attribute
{
        
    public string Name { get; private set; }

    public StateMetadataAttribute(string stateName)
    {
        this.Name = stateName;
    }
}
&lt;/pre&gt;The implemented StateMEFFactory object Imports all the MetaData for each concrete IState class using Lazy, and makes a decision of which state to instantiate by calling the Value property. &lt;pre class="brush: csharp;"&gt;[ImportMany(typeof(IState))]
private IEnumerable&lt;Lazy&lt;IState, StateMetadata&gt;&gt; States { get; set; }

public StateMEFFactory(string name)
{
    var container = new CompositionContainer(new AssemblyCatalog(typeof(IState).Assembly));
    container.ComposeParts(this);
    this.Current = this.States.First(s =&gt; s.Metadata.Name.Equals(name)).Value;
}
        
public IState Current { get; private set; }
&lt;/pre&gt;&lt;iframe style="BORDER-BOTTOM: #dde5e9 1px solid; BORDER-LEFT: #dde5e9 1px solid; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ffffff; MARGIN: 3px; PADDING-LEFT: 0px; WIDTH: 240px; PADDING-RIGHT: 0px; HEIGHT: 66px; BORDER-TOP: #dde5e9 1px solid; BORDER-RIGHT: #dde5e9 1px solid; PADDING-TOP: 0px" marginheight="0" src="http://cid-df3a504ac854b960.skydrive.live.com/embedrowdetail.aspx/.Public/MEFFactoryPattern.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;br /&gt;
Enjoy..   &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-4409895089698896180?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/4409895089698896180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2010/02/mef-factory-pattern-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/4409895089698896180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/4409895089698896180'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2010/02/mef-factory-pattern-example.html' title='MEF (Factory Pattern Example)'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-2628319497285198645</id><published>2009-08-08T12:29:00.008-05:00</published><updated>2010-02-28T23:35:36.683-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF Watermark</title><content type='html'>If you have a scenario where you want to provide a watermark to show some text as “Draft” or provide a visual queue as to where to drop an item. WPF VisualBrush makes it very easy to add Text to the background of a control to makes it appear as a Watermark.&lt;br /&gt;
&lt;pre class="brush: xml;"&gt;&lt;ItemsControl.Background&gt;
   &lt;visualbrush Stretch="Uniform" AlignmentY="Center" &gt;
       &lt;VisualBrush.Visual&gt;
          &lt;label HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="Silver" Content="Visitor" FontFamily="Calibri" FontSize="16" FontWeight="Bold" &gt;
              &lt;Label.RenderTransform&gt;
                 &lt;rotatetransform Angle="270"&gt;&lt;/RotateTransform&gt;
              &lt;/Label.RenderTransform&gt;
           &lt;/Label&gt;
       &lt;/VisualBrush.Visual&gt;
    &lt;/VisualBrush&gt;
 &lt;/ItemsControl.Background&gt;
&lt;/pre&gt;&lt;a href="http://2.bp.blogspot.com/_d0ZESGyylkc/Sn22oWlxbFI/AAAAAAAAACw/OzDKNlFsZsY/s1600-h/WpfWatermark.png"&gt;&lt;img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 400px; DISPLAY: block; HEIGHT: 400px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5367647135270530130" border="0" alt="" src="http://2.bp.blogspot.com/_d0ZESGyylkc/Sn22oWlxbFI/AAAAAAAAACw/OzDKNlFsZsY/s400/WpfWatermark.png" /&gt;&lt;/a&gt; &lt;iframe style="BORDER-BOTTOM: #dde5e9 1px solid; BORDER-LEFT: #dde5e9 1px solid; PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #ffffff; MARGIN: 3px; PADDING-LEFT: 0px; WIDTH: 240px; PADDING-RIGHT: 0px; HEIGHT: 66px; BORDER-TOP: #dde5e9 1px solid; BORDER-RIGHT: #dde5e9 1px solid; PADDING-TOP: 0px" marginheight="0" src="http://cid-df3a504ac854b960.skydrive.live.com/embedrowdetail.aspx/.Public/WPF%20Watermark/WpfWatermark.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-2628319497285198645?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/2628319497285198645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2009/08/wpf-watermark.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/2628319497285198645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/2628319497285198645'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2009/08/wpf-watermark.html' title='WPF Watermark'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_d0ZESGyylkc/Sn22oWlxbFI/AAAAAAAAACw/OzDKNlFsZsY/s72-c/WpfWatermark.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1992668869069529692.post-4097343122692533535</id><published>2009-05-26T22:52:00.003-05:00</published><updated>2010-02-28T23:12:23.751-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WinForms'/><title type='text'>Extend the ReportViewer Toolbar</title><content type='html'>&lt;a href="http://4.bp.blogspot.com/_d0ZESGyylkc/Sh8m01jXTUI/AAAAAAAAACI/4_tAXe8_oMw/s1600-h/ReportViewerContainer.png"&gt;&lt;img alt="" border="0" height="71" id="BLOGGER_PHOTO_ID_5341030372255157570" src="http://4.bp.blogspot.com/_d0ZESGyylkc/Sh8m01jXTUI/AAAAAAAAACI/4_tAXe8_oMw/s320/ReportViewerContainer.png" style="cursor: hand; display: block; float: none; height: 70px; margin: 0px auto; text-align: center; width: 499px;" width="507" /&gt;&lt;/a&gt; &lt;br /&gt;
The ReportViewer control is a free redistributable control that enables embedding reports in .NET Windows application. The reference for Microsoft.ReportViewer.Common and Microsoft.ReportViewer.Winforms must be added to your project to use the control.&lt;br&gt;&lt;br /&gt;
The ReportViewer control contains a toolbar that can be easily extended. First create a class that inherits from the ReportViewer control. Next add the override for OnControlAdded. &lt;br /&gt;
&lt;pre class="brush: csharp;"&gt;protected override voidOnControlAdded(System.Windows.Forms.ControlEventArgs e)
{
this.SetToolStripItems(e.Control);
base.OnControlAdded(e);
}
&lt;/pre&gt;Next look for the ToolStrip control and just add your controls.&lt;br&gt;&lt;br /&gt;
&lt;pre class="brush: csharp;"&gt;private void SetToolStripItems(Control c)
{   
if (c is ToolStrip)    
{        
ToolStripItemCollection tsic = ((ToolStrip)c).Items;        
tsic.Insert(0, new ToolStripControlHost(new CheckBox());        
return;    
}    
for (int i = 0; i &amp;lt; c.Controls.Count; i++)    
{       
SetToolStripItems(c.Controls[i]);   
}
}
&lt;/pre&gt;I have included a sample project the contains the list of all controls in the ReportViewer Toolbar, and a sample routine to add your own controls.&lt;br&gt;&lt;br /&gt;
&lt;pre class="code"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-df3a504ac854b960.skydrive.live.com/embedrowdetail.aspx/.Public/ReportViewerToolbarExtension.zip" style="background-color: white; border-bottom: #dde5e9 1px solid; border-left: #dde5e9 1px solid; border-right: #dde5e9 1px solid; border-top: #dde5e9 1px solid; height: 66px; margin: 3px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 240px;"&gt;&lt;/iframe&gt;&lt;/pre&gt;&lt;br&gt;Enjoy…&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1992668869069529692-4097343122692533535?l=devgig.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://devgig.blogspot.com/feeds/4097343122692533535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://devgig.blogspot.com/2009/05/extend-reportviewer-toolbar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/4097343122692533535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1992668869069529692/posts/default/4097343122692533535'/><link rel='alternate' type='text/html' href='http://devgig.blogspot.com/2009/05/extend-reportviewer-toolbar.html' title='Extend the ReportViewer Toolbar'/><author><name>Geoff Niehaus</name><uri>http://www.blogger.com/profile/18106239671899431029</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='22' src='http://4.bp.blogspot.com/_d0ZESGyylkc/Sa4RiEdDSWI/AAAAAAAAABM/QzbqWhHwWOQ/S220/Geoff.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_d0ZESGyylkc/Sh8m01jXTUI/AAAAAAAAACI/4_tAXe8_oMw/s72-c/ReportViewerContainer.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
