<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Berke Sökhan - In English</title>
    <link>http://www.berkesokhan.com/blog/</link>
    <description>düşünceler / thoughts</description>
    <language>en-us</language>
    <copyright>Berke Sökhan</copyright>
    <lastBuildDate>Sun, 06 Dec 2009 09:20:24 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>berkesokhan@gmail.com</managingEditor>
    <webMaster>berkesokhan@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.berkesokhan.com/blog/Trackback.aspx?guid=584899a5-488b-4202-ad93-2b1ab6c85de6</trackback:ping>
      <pingback:server>http://www.berkesokhan.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.berkesokhan.com/blog/PermaLink,guid,584899a5-488b-4202-ad93-2b1ab6c85de6.aspx</pingback:target>
      <dc:creator>Berke Sökhan</dc:creator>
      <wfw:comment>http://www.berkesokhan.com/blog/CommentView,guid,584899a5-488b-4202-ad93-2b1ab6c85de6.aspx</wfw:comment>
      <wfw:commentRss>http://www.berkesokhan.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=584899a5-488b-4202-ad93-2b1ab6c85de6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">We recently started to build a desktop
application with WPF and MVVM. 
<br /><br />
When we had the need for a validation framework for our view inputs, I started to
look on internet to find "de facto" approach for MVVM and WPF in general. There are
lots of look-alike methods for validation. 
<br /><br />
For validation I commonly saw three approaches:<br /><br /><ul><li>
Validation Rules on views<br /></li><li>
Hand coded validation on ViewModel setters</li><li>
Using some validation framework attributes (mostly System.ComponentModel.DataAnnotations)
on binded Model properties or ViewModel properties.<br /></li></ul><br />
For validation error user notification, people complain about how WPF lacks old Windows
Forms built in Error Provider support and invent their custom ones with IDataErrorInfo
interface.<br /><br />
The problems with the implementations I saw so far was they were like toy examples
or have overly complex implementations. One implementation outstands for me from the
rest. 
<br /><br />
In <a href="http://weblogs.asp.net/marianor/archive/2009/04/17/wpf-validation-with-attributes-and-idataerrorinfo-interface-in-mvvm.aspx">Mariano
Omar Rodriguez'</a>s validation approach, ViewModel decorates its properties with
Data Annotations for validation, and to check these attributes are really valid, ViewModel
uses some reflection and Linq Expressions. To show errors ViewModel also implements
IDataErrorInfo interface. While Mariano's approach seemed a little complex, if I could
carry complexity (IDataErrorInfo implementation and reflection methods/properties)
to a ViewModelBase class, adding new properties and validations would become fairly
easy. 
<br /><br />
I modified Mariano's code with generics to move all those overhead to a base class.
Two things I couldn't carry without friction were IDataErrorInfo's members this[string]
indexer and Error property, because these properties send "this" instances to reflective
methods for gathering IsValid infos from Data Annotation attributes. I was stuck there
for a good solution. My collegue Niyazi came with a solution which suggests we should
declare a T type property in ViewModelBase, and use T property instead of "this" in
ViewModelBase and actual ViewModels which inherit from ViewModelBase should assign
their selves to this generic typed property in their constructors. We were not totally
ok with this yet another overhead for the ViewModel. But it's less crappy or less
code from other solutions out there. So we settled for this solution.<br /><br />
You can grab the solution attached below. Please feel free to comment on this solution's
possible drawbacks.<br /><br /><a href="http://www.berkesokhan.com/blog/content/binary/Samples.Validation.BerkesVariant.rar">Samples.Validation.BerkesVariant.rar
(83.76 KB)</a><img width="0" height="0" src="http://www.berkesokhan.com/blog/aggbug.ashx?id=584899a5-488b-4202-ad93-2b1ab6c85de6" /></body>
      <title>A WPF MVVM Validation Implementation</title>
      <guid isPermaLink="false">http://www.berkesokhan.com/blog/PermaLink,guid,584899a5-488b-4202-ad93-2b1ab6c85de6.aspx</guid>
      <link>http://www.berkesokhan.com/blog/2009/12/06/AWPFMVVMValidationImplementation.aspx</link>
      <pubDate>Sun, 06 Dec 2009 09:20:24 GMT</pubDate>
      <description>We recently started to build a desktop application with WPF and MVVM. &lt;br&gt;
&lt;br&gt;
When we had the need for a validation framework for our view inputs, I started to
look on internet to find "de facto" approach for MVVM and WPF in general. There are
lots of look-alike methods for validation. 
&lt;br&gt;
&lt;br&gt;
For validation I commonly saw three approaches:&lt;br&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Validation Rules on views&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
Hand coded validation on ViewModel setters&lt;/li&gt;
&lt;li&gt;
Using some validation framework attributes (mostly System.ComponentModel.DataAnnotations)
on binded Model properties or ViewModel properties.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
For validation error user notification, people complain about how WPF lacks old Windows
Forms built in Error Provider support and invent their custom ones with IDataErrorInfo
interface.&lt;br&gt;
&lt;br&gt;
The problems with the implementations I saw so far was they were like toy examples
or have overly complex implementations. One implementation outstands for me from the
rest. 
&lt;br&gt;
&lt;br&gt;
In &lt;a href="http://weblogs.asp.net/marianor/archive/2009/04/17/wpf-validation-with-attributes-and-idataerrorinfo-interface-in-mvvm.aspx"&gt;Mariano
Omar Rodriguez'&lt;/a&gt;s validation approach, ViewModel decorates its properties with
Data Annotations for validation, and to check these attributes are really valid, ViewModel
uses some reflection and Linq Expressions. To show errors ViewModel also implements
IDataErrorInfo interface. While Mariano's approach seemed a little complex, if I could
carry complexity (IDataErrorInfo implementation and reflection methods/properties)
to a ViewModelBase class, adding new properties and validations would become fairly
easy. 
&lt;br&gt;
&lt;br&gt;
I modified Mariano's code with generics to move all those overhead to a base class.
Two things I couldn't carry without friction were IDataErrorInfo's members this[string]
indexer and Error property, because these properties send "this" instances to reflective
methods for gathering IsValid infos from Data Annotation attributes. I was stuck there
for a good solution. My collegue Niyazi came with a solution which suggests we should
declare a T type property in ViewModelBase, and use T property instead of "this" in
ViewModelBase and actual ViewModels which inherit from ViewModelBase should assign
their selves to this generic typed property in their constructors. We were not totally
ok with this yet another overhead for the ViewModel. But it's less crappy or less
code from other solutions out there. So we settled for this solution.&lt;br&gt;
&lt;br&gt;
You can grab the solution attached below. Please feel free to comment on this solution's
possible drawbacks.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://www.berkesokhan.com/blog/content/binary/Samples.Validation.BerkesVariant.rar"&gt;Samples.Validation.BerkesVariant.rar
(83.76 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://www.berkesokhan.com/blog/aggbug.ashx?id=584899a5-488b-4202-ad93-2b1ab6c85de6" /&gt;</description>
      <comments>http://www.berkesokhan.com/blog/CommentView,guid,584899a5-488b-4202-ad93-2b1ab6c85de6.aspx</comments>
      <category>.NET</category>
      <category>C#</category>
      <category>In English</category>
      <category>MVVM</category>
      <category>Teknik</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://www.berkesokhan.com/blog/Trackback.aspx?guid=a3a4dbdc-d55e-4835-a624-b403445a3fe8</trackback:ping>
      <pingback:server>http://www.berkesokhan.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.berkesokhan.com/blog/PermaLink,guid,a3a4dbdc-d55e-4835-a624-b403445a3fe8.aspx</pingback:target>
      <dc:creator>Berke Sökhan</dc:creator>
      <wfw:comment>http://www.berkesokhan.com/blog/CommentView,guid,a3a4dbdc-d55e-4835-a624-b403445a3fe8.aspx</wfw:comment>
      <wfw:commentRss>http://www.berkesokhan.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a3a4dbdc-d55e-4835-a624-b403445a3fe8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">From the author of The Reciprocality Project
white papers:<br /><br />
"Reciprocality is a private project to better understand the nature of the stresses
and challenges facing the<br />
software industry at the moment, particularly in respect of deep cultural issues in
the model of the nature of<br />
work. The intention is to be able to assist organisations to create conditions where
they can maximise their<br />
ability to attract, retain and get the best from able staff, while ensuring that younger
staff are provided with<br />
the conceptual and technical mentoring necessary to develop into aware and effective
creative engineers.<br /><br />
The project is evaluating 10 years teaching experience in a very broad social and
cultural context, and<br />
appears to be generating interesting results. It would seem that the way that software
engineering is<br />
perceived in society at large can tell us much about difficulties society will face
as the economy becomes<br />
more clearly dominated by Information Age issues."<br /><br />
- Alan Geoffrey Carter<br /><br />
I downloaded the whole <a href="http://www.datamodel.co.uk/Reciprocality/www.reciprocality.org/">project
site</a> in <a href="http://www.datamodel.co.uk/Reciprocality/www.reciprocality.org/pdf/reciprocality.pdf">PDF</a> and
checked out some of the articles. Though it may be dated old, I think it contains
some valuable information.<br /><p></p><img width="0" height="0" src="http://www.berkesokhan.com/blog/aggbug.ashx?id=a3a4dbdc-d55e-4835-a624-b403445a3fe8" /></body>
      <title>The Reciprocality Project</title>
      <guid isPermaLink="false">http://www.berkesokhan.com/blog/PermaLink,guid,a3a4dbdc-d55e-4835-a624-b403445a3fe8.aspx</guid>
      <link>http://www.berkesokhan.com/blog/2008/05/12/TheReciprocalityProject.aspx</link>
      <pubDate>Mon, 12 May 2008 06:46:12 GMT</pubDate>
      <description>From the author of The Reciprocality Project white papers:&lt;br&gt;
&lt;br&gt;
"Reciprocality is a private project to better understand the nature of the stresses
and challenges facing the&lt;br&gt;
software industry at the moment, particularly in respect of deep cultural issues in
the model of the nature of&lt;br&gt;
work. The intention is to be able to assist organisations to create conditions where
they can maximise their&lt;br&gt;
ability to attract, retain and get the best from able staff, while ensuring that younger
staff are provided with&lt;br&gt;
the conceptual and technical mentoring necessary to develop into aware and effective
creative engineers.&lt;br&gt;
&lt;br&gt;
The project is evaluating 10 years teaching experience in a very broad social and
cultural context, and&lt;br&gt;
appears to be generating interesting results. It would seem that the way that software
engineering is&lt;br&gt;
perceived in society at large can tell us much about difficulties society will face
as the economy becomes&lt;br&gt;
more clearly dominated by Information Age issues."&lt;br&gt;
&lt;br&gt;
- Alan Geoffrey Carter&lt;br&gt;
&lt;br&gt;
I downloaded the whole &lt;a href="http://www.datamodel.co.uk/Reciprocality/www.reciprocality.org/"&gt;project
site&lt;/a&gt; in &lt;a href="http://www.datamodel.co.uk/Reciprocality/www.reciprocality.org/pdf/reciprocality.pdf"&gt;PDF&lt;/a&gt; and
checked out some of the articles. Though it may be dated old, I think it contains
some valuable information.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.berkesokhan.com/blog/aggbug.ashx?id=a3a4dbdc-d55e-4835-a624-b403445a3fe8" /&gt;</description>
      <comments>http://www.berkesokhan.com/blog/CommentView,guid,a3a4dbdc-d55e-4835-a624-b403445a3fe8.aspx</comments>
      <category>Genel</category>
      <category>In English</category>
      <category>Sosyal</category>
    </item>
    <item>
      <trackback:ping>http://www.berkesokhan.com/blog/Trackback.aspx?guid=f6e29e4b-7142-4be3-bdae-249d32a698b9</trackback:ping>
      <pingback:server>http://www.berkesokhan.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.berkesokhan.com/blog/PermaLink,guid,f6e29e4b-7142-4be3-bdae-249d32a698b9.aspx</pingback:target>
      <dc:creator>Berke Sökhan</dc:creator>
      <wfw:comment>http://www.berkesokhan.com/blog/CommentView,guid,f6e29e4b-7142-4be3-bdae-249d32a698b9.aspx</wfw:comment>
      <wfw:commentRss>http://www.berkesokhan.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=f6e29e4b-7142-4be3-bdae-249d32a698b9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">A while (or may be a year ago), I blogged
about the White Screen of Darn. It came with the Visual Studio 2005 designer, and
occurs when for a reason designer couldn't render (generally referenced 3rd party)
UI components.<br /><br />
And, it happens again. 
<br /><br /><img src="http://www.berkesokhan.com/blog/content/binary/wsod2.gif" border="0" /><br /><br />
With the new Visual Studio 2008 interface also we have a new WSoD error screen :).<br /><br />
The problem shows in a form, when an assembly of a 3rd party UI component directly
or indirecly referenced multiple times. As the problematic error message will be like
"type Asy1.TypeA couldn't be cast to Asy1.TypeA", this shows us, VS designer wrongly
assumes same types as different types.<br /><br />
And here is the resolution: <b>Clean the project, and Build it again.</b><br /><br />
Then, VS corrects its mistake, and shows designer without errror. ;)<br /><br /><br /><img width="0" height="0" src="http://www.berkesokhan.com/blog/aggbug.ashx?id=f6e29e4b-7142-4be3-bdae-249d32a698b9" /></body>
      <title>White Screen of Darn: WSoD - Take 2</title>
      <guid isPermaLink="false">http://www.berkesokhan.com/blog/PermaLink,guid,f6e29e4b-7142-4be3-bdae-249d32a698b9.aspx</guid>
      <link>http://www.berkesokhan.com/blog/2008/05/02/WhiteScreenOfDarnWSoDTake2.aspx</link>
      <pubDate>Fri, 02 May 2008 14:43:36 GMT</pubDate>
      <description>A while (or may be a year ago), I blogged about the White Screen of Darn. It came with the Visual Studio 2005 designer, and occurs when for a reason designer couldn't render (generally referenced 3rd party) UI components.&lt;br&gt;
&lt;br&gt;
And, it happens again. 
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.berkesokhan.com/blog/content/binary/wsod2.gif" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
With the new Visual Studio 2008 interface also we have a new WSoD error screen :).&lt;br&gt;
&lt;br&gt;
The problem shows in a form, when an assembly of a 3rd party UI component directly
or indirecly referenced multiple times. As the problematic error message will be like
"type Asy1.TypeA couldn't be cast to Asy1.TypeA", this shows us, VS designer wrongly
assumes same types as different types.&lt;br&gt;
&lt;br&gt;
And here is the resolution: &lt;b&gt;Clean the project, and Build it again.&lt;/b&gt;
&lt;br&gt;
&lt;br&gt;
Then, VS corrects its mistake, and shows designer without errror. ;)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://www.berkesokhan.com/blog/aggbug.ashx?id=f6e29e4b-7142-4be3-bdae-249d32a698b9" /&gt;</description>
      <comments>http://www.berkesokhan.com/blog/CommentView,guid,f6e29e4b-7142-4be3-bdae-249d32a698b9.aspx</comments>
      <category>.NET</category>
      <category>Araçlar</category>
      <category>IDE</category>
      <category>In English</category>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>