<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/wordpress-mu-1.2.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>WPF Reflections</title>
	<link>http://itknowledgeexchange.techtarget.com/wpf</link>
	<description></description>
	<pubDate>Wed, 14 May 2008 09:09:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=wordpress-mu-1.2.1</generator>
	<language>en</language>
			<item>
		<title>WPF Problems printing documents</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/wpf-problems-printing-documents/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/wpf-problems-printing-documents/#comments</comments>
		<pubDate>Wed, 14 May 2008 09:04:27 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[printing]]></category>

		<category><![CDATA[Windows Computing]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/wpf-problems-printing-documents/</guid>
		<description><![CDATA[Do you have problems printing documents in WPF?
My problem manifested itself when I tried to print a document from a FlowDocumentPageViewer (though the same is true from a FlowDocumentReader).
The problem I was getting was that if I had multiple pages, they would all be scaled and fitted onto the same size of printed page as [...]]]></description>
			<content:encoded><![CDATA[<p>Do you have problems printing documents in WPF?</p>
<p>My problem manifested itself when I tried to print a document from a FlowDocumentPageViewer (though the same is true from a FlowDocumentReader).<br />
The problem I was getting was that if I had multiple pages, they would all be scaled and fitted onto the same size of printed page as on the screen.</p>
<p>How do you get around this?<br />
Well the problem lies in the fact that the document is being shown on the screen which has a different size to the printed page.<br />
Realising that, the solution itself is simple - change the height and width of the document before printing it, like:</p>
<p>Assuming docRdr is a FlowDocumentPageViewer and prtDlg is a PrintDialog:</p>
<p>FlowDocument doc = docRdr.Document;<br />
doc.PageHeight  = prtDlg.PrintableAreaHeight;<br />
doc.PageWidth   = prtDlg.PrintableAreaWidth;<br />
prtDlg.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator, &#8220;Statement&#8221;);</p>
<p>Of course, you will need to remember to save the FlowDocument&#8217;s height and width, then re-apply after you have printed the document.</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/wpf-problems-printing-documents/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF Printing documents</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-documents/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-documents/#comments</comments>
		<pubDate>Wed, 14 May 2008 08:50:43 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[printing]]></category>

		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-documents/</guid>
		<description><![CDATA[I have blogged before on how you print a WPF element using the PrintVisual method in the PrintDialog class, which is very flexible as it will print any element derived from Systems.Windows.Media.Visual.
However, there is another weapon in the PrintDialog armoury, and that is the ability to print documents. Given the extensive document support in WPF, [...]]]></description>
			<content:encoded><![CDATA[<p>I have blogged before on how you print a WPF element using the PrintVisual method in the PrintDialog class, which is very flexible as it will print any element derived from Systems.Windows.Media.Visual.<br />
However, there is another weapon in the PrintDialog armoury, and that is the ability to print documents. Given the extensive document support in WPF, it comes as no surprise that you can easily print these documents.</p>
<p>To do that you need to get at the DocumentPaginator object - it&#8217;s purpose in life lies in managing content as pages which is just perfect for the job.<br />
You get at it by using the IDocumentPaginatorSource interface, like this:</p>
<p>assuming docRdr is a FlowDocumentScrollViewer</p>
<p>PrintDialog prtDlg = new PrintDialog();<br />
if(prtDlg.ShowDialog() == true)<br />
{</p>
<blockquote><p> prtDlg.PrintDocument(((IDocumentPaginatorSource)docRdr.Document).DocumentPaginator, &#8220;Statement&#8221;);</p></blockquote>
<p>}</p>
<p>This will print the document for you just fine</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-documents/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF Printing - use the printing page</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-use-the-printing-page/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-use-the-printing-page/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 14:24:20 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-use-the-printing-page/</guid>
		<description><![CDATA[From a previous post of mine, you can see how to easily increase the size of a WPF element in order to print it.
That&#8217;s not much use though as you are still only hard coding the sizing.
What would be better is to use the height and width of the paper that has been selected.
Lo and [...]]]></description>
			<content:encoded><![CDATA[<p>From a previous <a href="http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-why-is-it-small/" title="Printing in WPF">post</a> of mine, you can see how to easily increase the size of a WPF element in order to print it.<br />
That&#8217;s not much use though as you are still only hard coding the sizing.<br />
What would be better is to use the height and width of the paper that has been selected.</p>
<p>Lo and behold, thats easy to do, using the PrintDialog class itself.<br />
One further wrinkle is that you need to make sure that the actual element is resized, and you do that by telling it to resize itself.</p>
<p>Say you have an instance of PrintDialog called prtDlg:</p>
<p>Size pageSize = new Size(prtDlg.PrintableAreaWidth -30, prtDlg.PrintableAreaHeight - 30);<br />
grd.Measure(pageSize);<br />
grd.Arrange(new Rect(15, 15, pageSize.Width, pageSize.Height));</p>
<p>prtDlg.PrintVisual(grd, &#8220;My grid&#8221;);</p>
<p>Where grd is a Grid control containing a number of other elements</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-use-the-printing-page/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF Printing - why is it small</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-why-is-it-small/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-why-is-it-small/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 15:25:02 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-why-is-it-small/</guid>
		<description><![CDATA[When you get to printing in WPF, you will find it so much easier than printing in previous Microsoft UI design (ie Winforms and MFC). See a previous post of mine to see how easy.
One thing that does occur though, is that when you print your element/canvas/grid/whatever, it will usually go on the printer very [...]]]></description>
			<content:encoded><![CDATA[<p>When you get to printing in WPF, you will find it so much easier than printing in previous Microsoft UI design (ie Winforms and MFC). See a previous <a href="http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-using-printvisual/" title="Print using PrintVisual">post</a> of mine to see how easy.</p>
<p>One thing that does occur though, is that when you print your element/canvas/grid/whatever, it will usually go on the printer very small. Why is that?<br />
Actually, I think it is a good thing <img src='http://itknowledgeexchange.techtarget.com/wpf/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
What it means is that it&#8217;s printing exactly the same on the printer as on the screen, something we have been begging for, for ages [well since we&#8217;ve had GUI&#8217;s anyway].</p>
<p>So how can you make it bigger, well it&#8217;s pretty easy when you know how:</p>
<p>You simply make the element bigger by using a Transform before printing, like</p>
<p>grid.LayoutTransform = new ScaleTransform(6,6);<br />
printDlg.PrintVisual(grid, &#8220;My  vision&#8221;);</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-why-is-it-small/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF Printing using PrintVisual</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-using-printvisual/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-using-printvisual/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 14:48:50 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-using-printvisual/</guid>
		<description><![CDATA[To do a simple print in WPF, you can do the following:
PrintDialog prtDlg = new PrintDialog();
if(prtDlg.ShowDialog() == true)
{
prtDlg.PrintVisual(element, &#8220;A simple drawing&#8221;);
}
This will throw up the XP or Vista print dialog, and then print the element specified, no problems at all.
Actually there are a couple of problems:

The element is always lined up in the top left [...]]]></description>
			<content:encoded><![CDATA[<p>To do a simple print in WPF, you can do the following:</p>
<p>PrintDialog prtDlg = new PrintDialog();<br />
if(prtDlg.ShowDialog() == true)<br />
{<br />
prtDlg.PrintVisual(element, &#8220;A simple drawing&#8221;);<br />
}</p>
<p>This will throw up the XP or Vista print dialog, and then print the element specified, no problems at all.<br />
Actually there are a couple of problems:</p>
<ol>
<li>The element is always lined up in the top left of the printed page</li>
<li>If you haven&#8217;t specified any margin, the element might get cut off</li>
<li>There&#8217;s no pagination</li>
<li>It uses the same device independent system for printing as showing on the screen ,1:96, so an element 96 pixels wide will appear 1 inch wide on the printed paper</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/wpf-printing-using-printvisual/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Printing with WPF</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/printing-with-wpf/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/printing-with-wpf/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 14:37:20 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/printing-with-wpf/</guid>
		<description><![CDATA[How does printing work with WPF?
Well, actually, if anyone out there has ever worked with printing in MFC,  then it&#8217;s so advanced as to make you dizzy.
Even if you ever tried printing with Windows Forms, then printing in WPF is a bit of a revelation.
So how does it work?
Most of the printing stuff is [...]]]></description>
			<content:encoded><![CDATA[<p>How does printing work with WPF?</p>
<p>Well, actually, if anyone out there has ever worked with printing in MFC,  then it&#8217;s so advanced as to make you dizzy.<br />
Even if you ever tried printing with Windows Forms, then printing in WPF is a bit of a revelation.</p>
<p>So how does it work?</p>
<p>Most of the printing stuff is in the System.Printing namespace, and a good starting place is the PrintDialog class.<br />
By instantiating the PrintDialog class, you can display the standard xp or vista print dialog to allow the user to choose where to print something and how.</p>
<p>What else does it give you?</p>
<p>You can call two different methods to do printing:<br />
PrintVisual  - allows you print  any class that derives from System.Windows.Media.Visual - which is a lot <img src='http://itknowledgeexchange.techtarget.com/wpf/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
PrintDocument - allows you to print any DocumentPaginator, e.g. FlowDocument or XpsDocument.</p>
<p>And it just works <img src='http://itknowledgeexchange.techtarget.com/wpf/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/printing-with-wpf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Document Outline in VS2008 with WPF</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/using-document-outline-in-vs2008-with-wpf/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/using-document-outline-in-vs2008-with-wpf/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 23:02:27 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[VS2008]]></category>

		<category><![CDATA[Microsoft Windows]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/using-document-outline-in-vs2008-with-wpf/</guid>
		<description><![CDATA[I have recently rediscovered Document Outline in VS2008.
It was something that I relegated, in my head at least, to the world of web
However, I thought about a week ago - wouldn&#8217;t it be very handy if it showed me my complex xaml in a tree.
Lo and behold it did, andI could click on each node [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently rediscovered Document Outline in VS2008.</p>
<p>It was something that I relegated, in my head at least, to the world of web</p>
<p>However, I thought about a week ago - wouldn&#8217;t it be very handy if it showed me my complex xaml in a tree.<br />
Lo and behold it did, andI could click on each node and go straight to the relevant DataTemplate</p>
<p>It was a nice and clean way to navigate the page, and dare I say it, easier than using Blend.<br />
Obviously Blend has a lot of great features not in VS2008, but is a bit designer like for me sometimes</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/using-document-outline-in-vs2008-with-wpf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Data validation in WPF, my approach</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-my-approach/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-my-approach/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 23:03:39 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[Databinding]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-my-approach/</guid>
		<description><![CDATA[Whether to use IDataErrorInfo or ValidationRule - that is the question, as I posed in a previous post.
So , you may be wondering what do I do in my WPF projects?
Or you may not  
Well, I tend to use both!
I use IDataErrorInfo to provide validation in the business object itself, then derive extra classes [...]]]></description>
			<content:encoded><![CDATA[<p>Whether to use IDataErrorInfo or ValidationRule - that is the question, as I posed in a previous <a href="http://itknowledgeexchange.techtarget.com/wpf/validation/" title="Previous" target="_blank">post</a>.</p>
<p>So , you may be wondering what do I do in my WPF projects?<br />
Or you may not <img src='http://itknowledgeexchange.techtarget.com/wpf/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Well, I tend to use both!<br />
I use IDataErrorInfo to provide validation in the business object itself, then derive extra classes from ValidationRule when I want validation across different business objects.</p>
<p>I have tried making the Validation classes always separate from the pure data business classes, but  I found it to be counter productive and also counter intuitive.</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-my-approach/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Data validation in WPF using ValidationRule</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-using-validationrule/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-using-validationrule/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 23:01:23 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[Validation]]></category>

		<category><![CDATA[Databinding]]></category>

		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<category><![CDATA[Microsoft Windows]]></category>

		<category><![CDATA[Windows Computing]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-using-validationrule/</guid>
		<description><![CDATA[As I mentioned in a previous post, you can specify validation by creating a Validation class (or classes).
You do this by deriving a new class from the ValidationRule class and overriding the Validate method.
Why would you do this, instead of implementing IDataErrorInfo?
Well, if you wanted  to do validation across a number of objects, then [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in a previous <a href="http://itknowledgeexchange.techtarget.com/wpf/validation/" title="Validation overview">post</a>, you can specify validation by creating a Validation class (or classes).</p>
<p>You do this by deriving a new class from the ValidationRule class and overriding the Validate method.</p>
<p>Why would you do this, instead of implementing IDataErrorInfo?<br />
Well, if you wanted  to do validation across a number of objects, then this is the way to go.<br />
It also provides a level of separation from your business objects, leaving them to deal with business data and the validation objects to deal with validation.<br />
A downside is that it  is not backwardly compatible with WinForms <img src='http://itknowledgeexchange.techtarget.com/wpf/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>How do you tell your xaml to use it? By specifying it in the ValidationRules element of your binding - just like IDataErrorInfo.</p>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/data-validation-in-wpf-using-validationrule/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Data validation using IDataErrorInfo</title>
		<link>http://itknowledgeexchange.techtarget.com/wpf/data-validation-using-idataerrorinfo/</link>
		<comments>http://itknowledgeexchange.techtarget.com/wpf/data-validation-using-idataerrorinfo/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 08:49:10 +0000</pubDate>
		<dc:creator>Mark Shurmer</dc:creator>
		
		<category><![CDATA[WPF]]></category>

		<category><![CDATA[Databinding]]></category>

		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/wpf/data-validation-using-idataerrorinfo/</guid>
		<description><![CDATA[As per a previous post, how do you do data validation in WPF using IDataErrorInfo?
Well what does IDataErrorInfo give you? It defines two properties:
public string Error
{
get;
}
public string this[string columnName]
{
get;
}
When you implement these, you provide error validation for your WPF application.
How does that happen?
Well, it doesn&#8217;t automatically of course [no surprises there].
When you specify your binding [...]]]></description>
			<content:encoded><![CDATA[<p>As per a previous post, how do you do data validation in WPF using IDataErrorInfo?</p>
<p>Well what does IDataErrorInfo give you? It defines two properties:</p>
<p>public string Error<br />
{<br />
get;<br />
}</p>
<p>public string this[string columnName]<br />
{<br />
get;<br />
}</p>
<p>When you implement these, you provide error validation for your WPF application.</p>
<p>How does that happen?<br />
Well, it doesn&#8217;t automatically of course [no surprises there].</p>
<p>When you specify your binding in xaml, you need to specify either the ValidationRules element or the ValidatesOnDataErrors parameter:</p>
<blockquote><p>&lt;Binding Source=&#8221;{StaticResource tradeList}&#8221; Path=&#8221;Instrument&#8221; UpdateSourceTrigger=&#8221;PropertyChanged&#8221;&gt;</p>
<blockquote><p>     &lt;Binding.ValidationRules&gt;</p>
<blockquote><p>          &lt;DataErrorValidationRule&gt;</p></blockquote>
<p>&lt;/Binding.ValidationRules&gt;</p></blockquote>
<p>&lt;/Binding&gt;</p>
<p>or</p>
<p>&lt;Binding Source=&#8221;{StaticResource tradeList}&#8221; Path=&#8221;Instrument&#8221; ValidatesOnDataErrors=&#8221;true&#8221; /&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/wpf/data-validation-using-idataerrorinfo/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
