I wanted to allow the user to enter an address as a multi-line field rather than a group of single line edit boxes. In winforms, you can set the multiline property to true, but in WPF, you need to set 3 properties as described in this article;
http://adnan8t2p.blogspot.co.uk/2009/03/wpf-multiline-textbox.html
Friday, 25 May 2012
Friday, 18 May 2012
LINQ to dictionary
In the latest story, I wanted to list received manuscripts in deadline ascending order so that the user could prioritise their work. As the deadline field is part of the job entity, it wasn't as simple as just fetching a list of manuscripts. In needed the LINQ to return a dictionary of manuscript and deadline key pairs. Here is an article that I found that shows how this can be done:
http://stackoverflow.com/questions/245168/linq-to-sql-todictionary
http://stackoverflow.com/questions/245168/linq-to-sql-todictionary
Thursday, 10 May 2012
Styles, Data Triggers and State Machines
Highlighting ListView Items
I've not needed to post on here for a while as I've been busy building out Oxyrhynchus. Today I added a feature to display jobs that had been invoiced for, but were unpaid., The requirement was to have unpaid jobs that were 30 days past the invoice raised date to be highlighted. I found a good article explaining how to use style resources and data triggers to achieve this on the view:
http://www.codeproject.com/Articles/18585/Highlighting-Items-in-a-WPF-ListView
Replacing status enums with State Pattern
While fixing a small problem with the quick action button logic I became aware that my manuscript workflow logic had become distributed between three classes - the EntityBase class contained some default logic and the Manuscript and ManuscriptService classes also contained the received to returned state transitional logic. Although this is manageable now, it could quickly turn into a 'code smell' that would require refactoring. Typically, this would be addressed by refactoring to the State pattern and have state-based behaviour encapsulated. I've done some reading around this:
http://stackoverflow.com/questions/7217125/how-to-map-abstract-class-using-entity-code-first-and-state-pattern
http://stackoverflow.com/questions/10011859/state-pattern-and-domain-driven-design
I've not needed to post on here for a while as I've been busy building out Oxyrhynchus. Today I added a feature to display jobs that had been invoiced for, but were unpaid., The requirement was to have unpaid jobs that were 30 days past the invoice raised date to be highlighted. I found a good article explaining how to use style resources and data triggers to achieve this on the view:
http://www.codeproject.com/Articles/18585/Highlighting-Items-in-a-WPF-ListView
Replacing status enums with State Pattern
While fixing a small problem with the quick action button logic I became aware that my manuscript workflow logic had become distributed between three classes - the EntityBase class contained some default logic and the Manuscript and ManuscriptService classes also contained the received to returned state transitional logic. Although this is manageable now, it could quickly turn into a 'code smell' that would require refactoring. Typically, this would be addressed by refactoring to the State pattern and have state-based behaviour encapsulated. I've done some reading around this:
http://stackoverflow.com/questions/7217125/how-to-map-abstract-class-using-entity-code-first-and-state-pattern
http://stackoverflow.com/questions/10011859/state-pattern-and-domain-driven-design
Saturday, 5 May 2012
Separation of concerns
Spent most of the day building out functionality by adding the ability to mark a manuscript found, from the smart search results list.
I don't want the smart search to know anything about individual domain entities such as jobs and manuscripts. I want the view-model to work with the abstract EntityBase. I used the EventAggregator to publish actions that the relevant modules could subscribe to.
I don't want the smart search to know anything about individual domain entities such as jobs and manuscripts. I want the view-model to work with the abstract EntityBase. I used the EventAggregator to publish actions that the relevant modules could subscribe to.
Thursday, 3 May 2012
Data Templates for Hetrogeneous Collections
Today, I added manuscripts to the smart search module. This meant that my search results needed to display a representation of both contact and manuscript data in the results list. One simple way to achieve this would be to implement a common interface that a single data template would present. However, I wanted the flexibility of different representations for the differing data types. The solution to this is to use the DataType property on DataTemplate to create an implicit data template. This had the effect of applying the template to all instances of that type.
See DataType property section in this article:
http://msdn.microsoft.com/en-us/library/ms742521.aspx
See DataType property section in this article:
http://msdn.microsoft.com/en-us/library/ms742521.aspx
Tuesday, 1 May 2012
Prism Event Aggregator
Before I start on the manuscript workflow stories, I wanted to split out the manuscript entry view from the job module into it's own module. I then wanted the job module to fire an event when it opened the job details view, so that the new manuscript module knew when to open and embed the manuscript entry view.
The event aggregator mechanism provided by the prism library is quite straightforward. However I did run into a problem that when I published an event, the subscriber didn't pick it up. The issue was down to weak references and the fact that the module instance is garbage collected almost straight after initialisation.
Here's an article that explains the situation:
http://neverindoubtnet.blogspot.co.uk/2009/05/prism-event-aggregator-subscription.html
The event aggregator mechanism provided by the prism library is quite straightforward. However I did run into a problem that when I published an event, the subscriber didn't pick it up. The issue was down to weak references and the fact that the module instance is garbage collected almost straight after initialisation.
Here's an article that explains the situation:
http://neverindoubtnet.blogspot.co.uk/2009/05/prism-event-aggregator-subscription.html
Subscribe to:
Posts (Atom)