<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Avivo Tech Blog &#187; Render</title>
	<atom:link href="http://tech.avivo.si/tag/render/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>ASP .NET MVC: How to render View into a string</title>
		<link>http://tech.avivo.si/2010/03/asp-net-mvc-how-to-render-view-into-a-string/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=asp-net-mvc-how-to-render-view-into-a-string</link>
		<comments>http://tech.avivo.si/2010/03/asp-net-mvc-how-to-render-view-into-a-string/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 21:38:36 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[Render]]></category>
		<category><![CDATA[render view to string in mvc]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[view]]></category>
		<category><![CDATA[view to html in mvc]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=472</guid>
		<description><![CDATA[Sometimes a developer needs to render a View as string. Practical scenario would be to create an obvious View and send it via e-mail instead displaying it in browser. Here is a simple way to extract content from a rendered View: Implement RenderViewToString method public class HomeController : Controller { protected string RenderViewToString(string viewName, object [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes a developer needs to render a View as string. Practical scenario would be to create an obvious View and send it via e-mail instead displaying it in browser. Here is a simple way to extract content from a rendered View:</p>
<p>Implement <em>RenderViewToString </em>method</p>
<pre class="c-sharp">public class HomeController : Controller
{
  protected string RenderViewToString(string viewName, object model)
  {
    string result = null;
    var view = ViewEngines.Engines.FindView(this.ControllerContext, viewName, null).View;
    if (view != null)
    {
      var sb = new StringBuilder();
      using (var writer = new StringWriter(sb))
      {
        var viewContext = new ViewContext(this.ControllerContext, view,
              new ViewDataDictionary(model), new TempDataDictionary(), writer);
        view.Render(viewContext, writer);
        writer.Flush();
      }
      result = sb.ToString();
    }
    return result;
  }
}</pre>
<p>Call it in your <em>action </em>method</p>
<pre class="c-sharp">//Somewhere in HomeController...
public ActionResult Index()
{
    //Render a View named 'Email' to string variable named 'content'
    //Second parameter (model) can be null
    string content = RenderViewToString("Email", new EmailModel());

    //Do something with the content, e.g. send it to e-mail

    //This does nothing to do with rendered string
    return View();
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/03/asp-net-mvc-how-to-render-view-into-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WriteableBitmap does not Render()?!</title>
		<link>http://tech.avivo.si/2009/12/writeablebitmap-does-not-render/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=writeablebitmap-does-not-render</link>
		<comments>http://tech.avivo.si/2009/12/writeablebitmap-does-not-render/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 16:36:32 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Warnings]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[not]]></category>
		<category><![CDATA[raster]]></category>
		<category><![CDATA[Render]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[vector]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[WriteableBitmap]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=223</guid>
		<description><![CDATA[We spent quite some time working on a Silverlight deep zoom application. Like in other projects, a problem appears sooner or later. This time with the WriteableBitmap that couldn&#8217;t take screenshot of a basic shape. //Simple ellipse (green circle) Ellipse element = new Ellipse() { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Green) [...]]]></description>
			<content:encoded><![CDATA[<p>We spent quite some time working on a Silverlight deep zoom application. Like in other projects, a problem appears sooner or later. This time with the <strong>WriteableBitmap</strong> that couldn&#8217;t take screenshot of a basic shape.</p>
<pre class="c-sharp">//Simple ellipse (green circle)
Ellipse element = new Ellipse()
{
	Width = 50,
	Height = 50,
	Fill = new SolidColorBrush(Colors.Green)
};

//WriteableBitmap current = new WriteableBitmap(50, 50);
//current.Render(element, new MatrixTransform()); //DOES NOT WORK!!! - renders blank transparent image

//But with the constructor works fine
WriteableBitmap bitmap = new WriteableBitmap(element, new MatrixTransform());

//Ellipse captured as raster image painted on a panel's background
Grid grid = new Grid()
{
	Width = 50,
	Height = 50,
	Background = new ImageBrush() { ImageSource = bitmap }
};</pre>
<p>Summary for the Render() method says: <em>&#8220;Renders an element within the bitmap.&#8221;</em><br />
<strong>Render()</strong> method didn&#8217;t output required result but <strong>using constructor instead</strong> of the method did do the job. Input parameters were the same.</p>
<p>Maybe Render() method do something else, maybe it is a problem with Vista 64-bit&#8230;</p>
<p>Anyway, WriteableBitmap is very useful in Silverlight 3, luckily it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/12/writeablebitmap-does-not-render/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

