<?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>C# .NET Application Development Archives | DMC, Inc.</title>
	<atom:link href="https://static.dmcinfo.com/blog/tag/c-net-application-development/feed/index.xml" rel="self" type="application/rss+xml" />
	<link></link>
	<description></description>
	<lastBuildDate>Fri, 21 Aug 2026 14:29:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://static.dmcinfo.com/wp-content/uploads/2025/04/site-icon-150x150.png</url>
	<title>C# .NET Application Development Archives | DMC, Inc.</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Creating a Slackbot Personal Assistant with .NET and an Office Fish</title>
		<link>https://static.dmcinfo.com/blog/24580/creating-a-slackbot-personal-assistant-with-net-and-an-office-fish/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Mon, 06 Mar 2017 15:33:13 +0000</pubDate>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Boston]]></category>
		<category><![CDATA[Culture]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[IoT]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/24580/creating-a-slackbot-personal-assistant-with-net-and-an-office-fish/</guid>

					<description><![CDATA[<p>It wasn&apos;t too long ago that DMC Boston added a Particle Internet Button&#160;to remind us to feed our fish, Stevie. With Stevie doing so well, and DMC&apos;s FedEx Day&#160;coming up, we started brainstorming of what else could we do. We landed on turning Stevie the fish into an alternate online personality in the form of [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/24580/creating-a-slackbot-personal-assistant-with-net-and-an-office-fish/">Creating a Slackbot Personal Assistant with .NET and an Office Fish</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">It wasn&apos;t too long ago that DMC Boston added a <a href="https://static.dmcinfo.com/latest-thinking/blog/id/9290/using-iot-to-feed-a-fishn">Particle Internet Button</a>&nbsp;to remind us to feed our fish, Stevie. With Stevie doing so well, and DMC&apos;s <a href="https://static.dmcinfo.com/latest-thinking/blog/id/9369/fedex-day-fosters-continuous-innovation">FedEx Day</a>&nbsp;coming up, we started brainstorming of what else could we do. We landed on turning Stevie the fish into an alternate online personality in the form of a personal assistant bot!</p>

<p class="wp-block-paragraph">Automated personal assistants are everywhere these days. Siri and Google Now keep us talking to our phones. Amazon Echo&nbsp;and Google Homes are in our houses. They are all playing our music, ordering our Ubers, and answering our questions about entertainment, hard news, random facts, etc. The problem? DMC didn&apos;t have one too.</p>

<h2 class="wp-block-heading">StevieBot the Personal Assistant</h2>

<p class="wp-block-paragraph">Instead of being jealous, we engineered away our problem and DMC now has StevieBot!</p>

<figure class="wp-block-image"><img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/hi_pic.png"  /></figure>

<p class="wp-block-paragraph">StevieBot can do a lot of things like report the weather, search Wikipedia, and define words for us.</p>

<figure class="wp-block-image"><img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/weather_pic.png"  /></figure>

<p class="wp-block-paragraph">He can even tell us jokes.</p>

<figure class="wp-block-image"><img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/joke_pic.png"  /></figure>

<p class="wp-block-paragraph">Based on the <a href="https://github.com/jammerware/margiebot/wiki">MargieBot architecture</a>, DMC&apos;s StevieBot has a simple framework for .NET with a great library. You can find all the resources you need at MargieBot to begin creating your own custom Slackbots.</p>

<h2 class="wp-block-heading">SlackBot Framework Functionality&nbsp;</h2>

<p class="wp-block-paragraph">The framework operates by creating a bot configuration (i.e. giving your bot a personality). Like the fish who came before him, StevieBot needed that special &quot;something&quot; that makes him part of the DMC family.&nbsp;</p>

<p class="wp-block-paragraph">To achieve this &quot;personality&quot;, the program loads various custom responders that you create.</p>

<p class="wp-block-paragraph">The program then establishes a connection with Slack (as well as any other webs services) using a unique API key.</p>

<h2 class="wp-block-heading">Slack to Bot Implementation</h2>

<ol class="wp-block-list">
 <li>In Slack, implement StevieBot as a <a href="https://api.slack.com/bot-users">Bot User</a>.</li>
 <li>Create a custom Slackbot by going to your team&rsquo;s settings page.</li>
 <li>Select create a new bot user.</li>
</ol>

<p class="wp-block-paragraph"><strong>Take note: To establish communication between the framework and Slack, you need the auto-generated API Token.</strong></p>

<h2 class="wp-block-heading">Bot Considerations &#8211; Bot Parameters</h2>

<p class="wp-block-paragraph">Once initialized, the framework waits for Slack to send a notification that it has received a message. The framework then parses the message and determines if the bot should respond.</p>

<p class="wp-block-paragraph">The framework considers:</p>

<ul class="wp-block-list">
 <li>Who sent the message?</li>
 <li>Was the bot mentioned in the message?</li>
 <li>Was it a direct message?</li>
</ul>

<p class="wp-block-paragraph"><strong>Take note: These parameters are all configurable and can to determine how the bot will respond.</strong></p>

<p class="wp-block-paragraph">The framework checks the message for regular expressions using .NET&rsquo;s included RegEx engine. The results of the checks determine the appropriate responder.</p>

<p class="wp-block-paragraph"><strong>Finally, StevieBot creates a message and posts it back to Slack!</strong></p>

<h2 class="wp-block-heading">The Future &#8211; SlackBots and Particle Cloud Communication&nbsp;</h2>

<p class="wp-block-paragraph">StevieBot also communicates with the Particle Cloud. This paves the way for potential IoT fish tank functionality in the future. We&rsquo;ve already purchased some components including pH, temperature, and turbidity sensors.</p>

<p class="wp-block-paragraph">For now, we can ask Stevie to poll the various Particle boards around the office and check their status.</p>

<figure class="wp-block-image"><img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/particle_pic_1.png"  /></figure>

<h2 class="wp-block-heading">Conclusion</h2>

<p class="wp-block-paragraph">Built on an expandable framework, plans exist to implement in StevieBot aspects of the neural network architecture for machine learning so StevieBot can be more proactive with messages. The future options are endless, but an assistant who can recommend lunches based on individual tastes sounds like a perfect start.</p>

<p class="wp-block-paragraph">Fun projects aren&apos;t the only thing we do! <a href="https://static.dmcinfo.com/services/application-development/pc-application-development/c-net">Explore more of&nbsp;</a><a href="https://static.dmcinfo.com/services/application-development/pc-application-development/c-net">DMC&apos;s</a><a href="https://static.dmcinfo.com/services/application-development/pc-application-development/c-net">&nbsp;C# </a><a href="https://static.dmcinfo.com/services/application-development/pc-application-development/c-net">and .</a><a href="https://static.dmcinfo.com/services/application-development/pc-application-development/c-net">Net Development Services</a>.</p>

<p class="wp-block-paragraph">If you&apos;re sorry you missed another FedEx Day with us, <a href="https://static.dmcinfo.com/careers">check out our Career&nbsp;page</a>!</p>
<p>The post <a href="https://static.dmcinfo.com/blog/24580/creating-a-slackbot-personal-assistant-with-net-and-an-office-fish/">Creating a Slackbot Personal Assistant with .NET and an Office Fish</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Easy XML Parsing in C#/.NET With the HTML Agility Pack</title>
		<link>https://static.dmcinfo.com/blog/24980/easy-xml-parsing-in-c-net-with-the-html-agility-pack/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Mon, 31 Oct 2016 16:57:45 +0000</pubDate>
				<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[SDK, API, and Driver]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/24980/easy-xml-parsing-in-c-net-with-the-html-agility-pack/</guid>

					<description><![CDATA[<p>In 2006, the newspaper USA Today&#160;included the Internet in its list of the &#8220;New Seven Wonders of the World.&#8221; The Internet has democratized access to vast stores of information in an unprecedented way&#160;and has transformed many aspects of education, industry, and society. This glut of information can give tremendous insight into everything from trends in [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/24980/easy-xml-parsing-in-c-net-with-the-html-agility-pack/">Easy XML Parsing in C#/.NET With the HTML Agility Pack</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In 2006, the newspaper <em>USA Today</em>&nbsp;included the Internet in its list of the &#8220;New Seven Wonders of the World.&#8221; The Internet has democratized access to vast stores of information in an unprecedented way&nbsp;and has transformed many aspects of education, industry, and society. This glut of information can give tremendous insight into everything from trends in the price of chop sticks&nbsp;to predicting regional flu outbreaks across the globe &#8211; if you know how to efficiently access it.&nbsp;</p>



<p class="wp-block-paragraph">I recently started a personal project to monitor the real estate market in Houston to gain insight into trends in pricing, neighborhood composition, construction, etc. One vital piece of the puzzle was reliably and efficiently gathering detailed information on specific properties to monitor over time. Using <a href="http://www.zillow.com/howto/api/APIOverview.htm">Zillow.com&#8217;s Developer APIs</a> and the <a href="https://html-agility-pack.net/">HTML Agility Pack</a>, I was able to spin up a prototype over coffee one Sunday morning, and I wanted to share my experience using this powerful C# library.</p>



<h2 id="h-the-zillow-api" class="wp-block-heading">The Zillow API</h2>



<p class="wp-block-paragraph">The majority of modern websites use JSON as the data exchange format, as it is easily consumed by the widely-used JavaScript language, but there are a significant number of sites (including Zillow.com) that use XML as the exchange format. There are advantages and disadvantages to each, but both formats are straightforward to parse and are human-readable.&nbsp;</p>



<p class="wp-block-paragraph">Zillow provides several useful APIs, and I chose <a href="https://www.bridgeinteractive.com/developers/zillow-group-data/" type="link" id="https://www.bridgeinteractive.com/developers/zillow-group-data/" target="_blank" rel="noreferrer noopener">GetDeepSearchResults</a> because it encapsulates most of the data I want to track in my application. The documentation is refreshingly complete and useful: you can see details about each field, the XML schema, error codes, and an example usage. After obtaining my developer API key, I scratched out a few lines of code to load the results.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly> private void LoadResults(string property)
 {
     // Argument "property" is a URL-encoded string containing a single property address, city, and state
     string addr = "http://www.zillow.com/webservice/GetDeepSearchResults.htm";
     string key = "?&#91;My_API_Key&#93;&amp;";
     string results = String.Empty;

     // Create a new HTTP client to communicate with the Zillow server
     HttpClient client = new HttpClient();
     client.BaseAddress = new Uri(addr);

     // Load the results of the querty
     HttpResponseMessage response = client.GetAsync(key + property).Result;
     if (response.IsSuccessStatusCode)
     {
         results = response.Content.ReadAsStringAsync();
     }
     else
     {
         Debug.WriteLine("Web call failed with code " + response.StatusCode);
     }
     return results;
 }</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4"> </span><span style="color: #569CD6">private</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">LoadResults</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">property</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4"> {</span></span>
<span class="line"><span style="color: #6A9955">     // Argument &quot;property&quot; is a URL-encoded string containing a single property address, city, and state</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">addr</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;http://www.zillow.com/webservice/GetDeepSearchResults.htm&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">key</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;?&#91;My_API_Key&#93;&amp;&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">results</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">String</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Empty</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">     // Create a new HTTP client to communicate with the Zillow server</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #4EC9B0">HttpClient</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">client</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">HttpClient</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">client</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">BaseAddress</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Uri</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">addr</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">     // Load the results of the querty</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #4EC9B0">HttpResponseMessage</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">response</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">client</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">GetAsync</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">key</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">property</span><span style="color: #D4D4D4">).</span><span style="color: #9CDCFE">Result</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">response</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">IsSuccessStatusCode</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">     {</span></span>
<span class="line"><span style="color: #D4D4D4">         </span><span style="color: #9CDCFE">results</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">response</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Content</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">ReadAsStringAsync</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">     }</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #C586C0">else</span></span>
<span class="line"><span style="color: #D4D4D4">     {</span></span>
<span class="line"><span style="color: #D4D4D4">         </span><span style="color: #9CDCFE">Debug</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">WriteLine</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Web call failed with code &quot;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">response</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">StatusCode</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">     }</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">results</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4"> }</span></span></code></pre></div>



<p class="wp-block-paragraph">The LoadResults function takes in a well-formed URL-encoded property listing string that meets the requirements listed in the API documentation, and returns either an empty string (if the API call failed) or an XML-encoded string containing the property details.</p>



<h2 id="h-parsing-with-agility" class="wp-block-heading">Parsing with Agility</h2>



<p class="wp-block-paragraph">I could have spent some time brewing up a <a href="https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx">RegEx</a>-powered parser for the XML results &#8211;&nbsp;after all, this is a well-documented API, and I know what to expect from each call. But why re-invent the wheel? It&#8217;s also worth pointing out that not all APIs (or web pages, which you can also easily scrape with the HTML Agility Pack) are as consistent and well-formed, so your homebrewed parser might work for a while until it tries to handle a malformed response.&nbsp;</p>



<p class="wp-block-paragraph">Using the Agility Pack and the Zillow documentation, I can easily parse out the XML tags I care about without writing a single regex.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly> private PropertyData ParseResults(string results)
 {
     // Create an instance of the PropertyData to store the results
     PropertyData data = new PropertyData();

     // Load the API result string
     HtmlDocument doc = new HtmlDocument();
     doc.LoadHtml(results);

     // Find the parameters that will be tracked
     var zpid = doc.DocumentNode.Descendants("zpid").FirstOrDefault().InnerText;
     var finSize = doc.DocumentNode.Descendants("finishedSqFt").FirstOrDefault().InnerText;
     var zestValue = doc.DocumentNode.Descendants("amount").FirstOrDefault().InnerText;
     var baths = doc.DocumentNode.Descendants("bathrooms").FirstOrDefault().InnerText;
     var beds = doc.DocumentNode.Descendants("bedrooms").FirstOrDefault().InnerText;

     // Parse these value strings into their expected data types
     data.Zpid = int.Parse(zpid);
     data.FinishedSize = int.Parse(finSize);
     data.ZestValue = double.Parse(zestValue);
     data.Bathrooms = double.Parse(baths);
     data.Bedrooms = double.Parse(beds);

     return data;
 }</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4"> </span><span style="color: #569CD6">private</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">PropertyData</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">ParseResults</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">results</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4"> {</span></span>
<span class="line"><span style="color: #6A9955">     // Create an instance of the PropertyData to store the results</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #4EC9B0">PropertyData</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">PropertyData</span><span style="color: #D4D4D4">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">     // Load the API result string</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #4EC9B0">HtmlDocument</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">HtmlDocument</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">LoadHtml</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">results</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">     // Find the parameters that will be tracked</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">zpid</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">DocumentNode</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Descendants</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;zpid&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">FirstOrDefault</span><span style="color: #D4D4D4">().</span><span style="color: #9CDCFE">InnerText</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">finSize</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">DocumentNode</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Descendants</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;finishedSqFt&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">FirstOrDefault</span><span style="color: #D4D4D4">().</span><span style="color: #9CDCFE">InnerText</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">zestValue</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">DocumentNode</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Descendants</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;amount&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">FirstOrDefault</span><span style="color: #D4D4D4">().</span><span style="color: #9CDCFE">InnerText</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">baths</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">DocumentNode</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Descendants</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;bathrooms&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">FirstOrDefault</span><span style="color: #D4D4D4">().</span><span style="color: #9CDCFE">InnerText</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">beds</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">doc</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">DocumentNode</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Descendants</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;bedrooms&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">FirstOrDefault</span><span style="color: #D4D4D4">().</span><span style="color: #9CDCFE">InnerText</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">     // Parse these value strings into their expected data types</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Zpid</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">int</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Parse</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">zpid</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">FinishedSize</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">int</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Parse</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">finSize</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">ZestValue</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">double</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Parse</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">zestValue</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Bathrooms</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">double</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Parse</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">baths</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Bedrooms</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">double</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Parse</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">beds</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">     </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4"> }</span></span></code></pre></div>



<p class="wp-block-paragraph">That&#8217;s all there is to it! No bulky regular expressions or clunky homebrewed parsing code. For clarity, I stripped out a lot of input sanitation and error handling code, so don&#8217;t forget to check for exception conditions!</p>



<h2 id="h-other-applications" class="wp-block-heading">Other Applications</h2>



<p class="wp-block-paragraph">You may have an inkling that a parsing tool like the HTML Agility Pack can work for more than just parsing XML responses. You would be correct. Another key area where this library can come into play is data scraping (or web data extraction). If an API is not available or doesn&#8217;t give you all of the information you need, you can load the web page and parse the whole thing for the data you need.&nbsp;</p>



<p class="wp-block-paragraph">It&#8217;s very important to note that web scraping may violate the Terms of Use for a site, and if your scraping tool misbehaves and loads the webpage at a high rate, you run the risk of compromising the site&#8217;s resources and awaking the angry IT department kraken! Please be considerate, review the <a href="https://www.bloombergindustry.com/" type="link" id="https://www.bloombergindustry.com/">legality</a> of your application, and scrape responsibly!</p>



<p class="wp-block-paragraph">If you&#8217;ve used the HTML Agility Pack in an application or have questions about how I used it in mine, leave a comment below! Happy coding.</p>



<p class="wp-block-paragraph"><strong><a href="https://static.dmcinfo.com/services/application-development/web-application-development">Learn more about DMC&#8217;s web application development.</a></strong></p>
<p>The post <a href="https://static.dmcinfo.com/blog/24980/easy-xml-parsing-in-c-net-with-the-html-agility-pack/">Easy XML Parsing in C#/.NET With the HTML Agility Pack</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CAD Models in C#: Developing with Eyeshot</title>
		<link>https://static.dmcinfo.com/blog/25008/cad-models-in-c-developing-with-eyeshot/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Tue, 25 Oct 2016 15:48:49 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25008/cad-models-in-c-developing-with-eyeshot/</guid>

					<description><![CDATA[<p>DMC recently developed some desktop applications for clients in C# that require 3D modeling. We’ve been using a third-party CAD tool developed by devDept called Eyeshot. If you are working in the world of graphic design, 3D animation rendering, or physics simulations, there could be better options for your needs, like gaming engines such as [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25008/cad-models-in-c-developing-with-eyeshot/">CAD Models in C#: Developing with Eyeshot</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">DMC recently developed some desktop applications for clients in C# that require 3D modeling. We’ve been using a third-party CAD tool developed by devDept called <a href="https://www.devdept.com/" target="_blank">Eyeshot</a>. If you are working in the world of graphic design, 3D animation rendering, or physics simulations, there could be better options for your needs, like gaming engines such as <a href="https://unity3d.com/" target="_blank">Unity</a>&nbsp;and <a href="http://www.nvidia.com/object/physx-9.16.0318-driver.html" target="_blank">nVidia PhysX</a>.</p>



<p class="wp-block-paragraph">However, if you are working in the engineering world of CAD files, Eyeshot is by far the best tool available for C#. There is a lot of great functionality out of the box and it is pretty extensible. Without further ado, I’ll share a few of the fun things we’ve done!</p>



<h2 id="h-file-compatibility" class="wp-block-heading">File Compatibility</h2>



<p class="wp-block-paragraph">We’ve used Eyeshot to pull in DXF, DWG, STL (including Mesh entities), and STEP files. It also supports reading and saving OBJ, IGES, and several other formats. Conversion between formats can sometimes take some work depending on the details, but is generally doable.</p>


<div style="float: right; width: 320px; margin-left: 5px;"> </div>


<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="320" height="240" src="https://static.dmcinfo.com/wp-content/uploads/2016/10/Eyeshot-Auto-Transparency-50.gif" alt="automatic transparency " class="wp-image-36456"/></figure>



<p class="wp-block-paragraph"><br> <strong>Demonstration of real-time movement behind objects and automatic transparency to keep it visible </strong><br> <em>Model source: Modern Building by S. Prasanth</em><br>  </p>


<div style="float: right; width: 320px; clear: right; margin-left: 5px;"> </div>


<figure class="wp-block-image size-full"><img decoding="async" width="320" height="290" src="https://static.dmcinfo.com/wp-content/uploads/2016/10/Eyeshot-Collision-50.gif" alt="collision detection" class="wp-image-36458"/></figure>



<p class="wp-block-paragraph"><br> <strong>Our custom object creation, editing, and collision detection algorithms on display</strong><br> <em>Model source: 6mm Bolt Head Knob for Unscrewing by Aidan McMaster</em></p>


</div>


<h2 id="h-point-and-object-creation" class="wp-block-heading">Point and Object Creation</h2>



<p class="wp-block-paragraph">You can use Eyeshot to build your own full-fledged CAD generator or editor. However, the applications we’ve been developing so far are not aimed at CAD jockeys. We’ve made some simple point, line, bar, and curve creation and editing tools. While Eyeshot has support for 3D mice, we are aiming at simple mouse or touch screen (and yes, multi-touch!) interfaces. Eyeshot has some nice multi-touch functionality out of the box, although we’ve found we had to build onto it with quite a bit of customization.</p>



<h2 id="h-real-time-updates-and-animation" class="wp-block-heading">Real-Time Updates and Animation</h2>



<p class="wp-block-paragraph">We’ve set up our application to show objects moving in real time by feeding in live, real world coordinates. This also can be used to show pre-recorded animations. Update rates of 60 frames per second are easily achievable.</p>



<h2 id="h-collision-detection" class="wp-block-heading">Collision Detection</h2>



<p class="wp-block-paragraph">We’ve had several uses for collision detection algorithms, which can always be a tricky subject. Generally game engines are better for collision detection as Eyeshot lacks this functionality out of the box, but we have implemented some of our own routines for multiple different purposes.</p>



<p class="wp-block-paragraph">One is to verify that created objects live in a valid space and don’t collide with other objects in a non-dynamic situation. The other is to verify whether or not there are collisions with moving objects. In both cases you always have to use an approximation method, such as hit boxes, and some innovative 3D geometry and math.</p>



<h2 id="h-skinning" class="wp-block-heading">Skinning</h2>



<p class="wp-block-paragraph">Eyeshot allows you to apply images (materials) to objects to add a little more life to the model. You also can adjust the transparency of different entities and layers. One cool feature we added was dynamic transparency to hide objects that are in the way of viewing a moving object.</p>



<p class="wp-block-paragraph">Overall, we look forward to continuing to use Eyeshot in future projects, especially as DevDept continues to improve the program and add new features requested by users.</p>



<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/services/application-development/desktop-application-development/c-net/">Learn more about DMC&#8217;s C# programming expertise and services.</a></p>
<p>The post <a href="https://static.dmcinfo.com/blog/25008/cad-models-in-c-developing-with-eyeshot/">CAD Models in C#: Developing with Eyeshot</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>6 Easy Steps to Get Started with MVC Module Development in DNN 8</title>
		<link>https://static.dmcinfo.com/blog/25071/6-easy-steps-to-get-started-with-mvc-module-development-in-dnn-8/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Fri, 14 Oct 2016 12:37:43 +0000</pubDate>
				<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[Dot Net Nuke]]></category>
		<category><![CDATA[HTML and CSS]]></category>
		<category><![CDATA[MS Visual Studio/.NET]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25071/6-easy-steps-to-get-started-with-mvc-module-development-in-dnn-8/</guid>

					<description><![CDATA[<p>In the beginning of the year,&#160;DNN (formerly DotNetNuke) was updated to support MVC modules. MVC is the latest version of ASP.NET in which the Model-View-Controller paradigm is at the core.&#160;This article won&#8217;t be a look into what MVC is or a comparison with WebForms, but instead will give a quick guide into starting DNN MVC [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25071/6-easy-steps-to-get-started-with-mvc-module-development-in-dnn-8/">6 Easy Steps to Get Started with MVC Module Development in DNN 8</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In the beginning of the year,&nbsp;DNN (formerly DotNetNuke) was updated to support MVC modules. MVC is the latest version of ASP.NET in which the Model-View-Controller paradigm is at the core.&nbsp;This article won&#8217;t be a look into what MVC is or a comparison with WebForms, but instead will give a quick guide into starting DNN MVC module development.</p>



<p class="wp-block-paragraph">While there are some guides available that give you similar information, I found it a bit difficult to get started developing MVC modules in DNN. For reference, the articles I used are at the bottom of this blog.</p>



<p class="wp-block-paragraph">Here&#8217;s an overview of the steps we&#8217;ll take to get started.</p>



<ol class="wp-block-list">
<li><a href="#prerequisites">Prerequisites</a></li>



<li><a href="#templates">Templates</a></li>



<li><a href="#setup">Setup</a></li>



<li><a href="#build">Build</a></li>



<li><a href="#installation">Installation</a></li>



<li><a href="#next-steps">Next Steps</a></li>



<li><a href="#references">References</a></li>
</ol>



<h2 id="prerequisites" class="wp-block-heading">1. Prerequisites</h2>



<p class="wp-block-paragraph">For this quick start, you&#8217;ll need a few things before we can dive in.</p>



<p class="wp-block-paragraph">First, you&#8217;ll need to have Visual Studio 2015 installed. The express editions have been reported to be incompatible with the templates we&#8217;ll be using later, but this may not be true by the time you&#8217;re reading this.</p>



<p class="wp-block-paragraph">Next, you&#8217;ll need to have IIS (Internet Information Services) setup with a local installation of DNN (version 8 or higher). There are many tutorials on how to do this around the web. You&#8217;ll need to install IIS and&nbsp;Microsoft SQL Server, then you can install DNN by downloading the latest _install.zip from <a href="https://github.com/dnnsoftware/Dnn.Platform/releases" target="_blank">DNN&#8217;s GitHub releases</a>.</p>



<p class="wp-block-paragraph">Once those are all set up, you&#8217;re ready to go.</p>



<h2 id="templates" class="wp-block-heading">2. Templates</h2>



<p class="wp-block-paragraph">You <em>could&nbsp;</em>create a module from scratch. But why would you do that when a DNN expert created templates for you to use? <a href="https://marketplace.visualstudio.com/items?itemName=Chris-Hammond.DotNetNukeDNNDevelopmentProjectTemplates" target="_blank" rel="noreferrer noopener">Download the templates from the Visual Studio Gallery</a>&nbsp;and run through the installation procedure.</p>



<h2 id="setup" class="wp-block-heading">3. Setup</h2>



<p class="wp-block-paragraph">Now that everything is set up, we can actually dive into creating the module.&nbsp;</p>



<p class="wp-block-paragraph">In Visual Studio, select File -&gt; New -&gt; Project</p>



<p class="wp-block-paragraph">In the New Project window, select Templates -&gt; Visual C# -&gt; DotNetNuke and you&#8217;ll see a listing of the types of projects the templates have provided.</p>



<p class="wp-block-paragraph">To create an MVC module, we&#8217;ll select DotNetNuke 8 C# DAL2 MVC Module. There are three other fields we must configure: Name, Location, and Solution name.</p>



<p class="wp-block-paragraph"><strong>Name: </strong>Enter a name for your project (it&#8217;s best not to use any spaces or special characters for this)</p>



<p class="wp-block-paragraph"><strong>Location:&nbsp;</strong>This is important to point this to the correct folder in DNN: /DesktopModules/MVC/.&nbsp;Depending on your installation directory, the folder should be something like C:\Dev\Projects\DMC_Website\Alpha\DesktopModules\MVC\ where &#8220;Alpha&#8221; is the root of your DNN installation.</p>



<p class="wp-block-paragraph"><strong>Solution name:</strong>&nbsp;We&#8217;re not actually going to be using this field. Uncheck&nbsp;the box on the right that says &#8220;Create directory for solution&#8221; and the solution name textbox will be greyed out.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/2016-10-28-12_40_42-New-Project.png" alt="Configuration of the DotNetNuke 8 C# DAL2 MVC Module Visual Studio Project"/></figure>



<p class="wp-block-paragraph">Confirm your settings look similar to mine and then click OK.</p>



<p class="wp-block-paragraph">A Project Setup Wizard dialog box will appear asking for some project information. Many of these are self explanatory, so I will only address the two that are a bit tricky.</p>



<p class="wp-block-paragraph"><strong>Namespace: </strong>Whatever namespace you want your module to live in. The templates will automatically include your project name in the namespace, so no need to enter it here.&nbsp;Make sure you include the last period. E.g. DMC.</p>



<p class="wp-block-paragraph"><strong>Local Dev URL:&nbsp;</strong>By default this is set up to point to dnndev.me, which is actually set up to point back to 127.0.0.1 (your localhost). What you enter here depends on what settings you&#8217;ve set your DNN install up with. For my installation, I access my local DNN install through http://localhost./ Therefore, I am going to enter localhost as my Local Dev URL.</p>



<p class="wp-block-paragraph">Initial values</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/2016-10-14-12_49_25-Project-Setup-Wizard.png" alt="DNN Template Setup Wizard Initial Values"/></figure>



<p class="wp-block-paragraph">Updated values (note: the owner website field includes https:// but the textbox isn&#8217;t large enough to display it. Be sure to include it in your URL.)</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/2016-10-28-12_42_14-Project-Setup-Wizard.png" alt="DNN Template Setup Wizard Updated Values"/></figure>



<p class="wp-block-paragraph">Once all fields have been complete, click OK.</p>



<h2 id="build" class="wp-block-heading">4. Build</h2>



<p class="wp-block-paragraph">Now that the initial project setup is complete, you&#8217;ll be presented with a web page in Visual Studio that says * Important *. These are steps that you should&nbsp;<strong>read carefully</strong>&nbsp;and follow to ensure your project will work correctly. I&#8217;ll provide a quick overview of these steps in case the original wording is confusing for anyone.</p>



<p class="wp-block-paragraph">First, check IIS to see if any of your folders were converted to virtual directories or applications. To do this, open IIS, expand your site&#8217;s dropdown and check what icon is displayed next to your DesktopModules folder or the MVC folder inside of the DesktopModules folder. If it&#8217;s anything other than a yellow folder, right click it and click remove.</p>



<p class="wp-block-paragraph">Next, in Visual Studio, right click and delete the web.config files that are in the solution.</p>



<p class="wp-block-paragraph">You can now build the module! change the solution configuration dropdown from Debug to Release and then select Build -&gt; Build</p>



<p class="wp-block-paragraph">You&#8217;ll get an install .zip file in your module&#8217;s install/ directory.</p>



<h2 id="installation" class="wp-block-heading">5. Installation</h2>



<p class="wp-block-paragraph">Now, in DNN, go to Hosts -&gt; Extensions and click Install Extension, selecting your install .zip file that you previously built.</p>



<p class="wp-block-paragraph">If everything goes well, then the module is now installed and can be placed on any page.</p>



<h2 id="next-steps" class="wp-block-heading">6. Next Steps</h2>



<p class="wp-block-paragraph">Once you&#8217;ve dragged the module into a page, you&#8217;ll see a demo application that includes multiple views, database interaction, and more. Simply build the project in debug mode to automatically copy the new DLL to the /bin folder.</p>



<h2 id="references" class="wp-block-heading">7. References</h2>



<ul class="wp-block-list">
<li><a href="https://www.chrishammond.com/tag/dotnetnuke" type="link" id="https://www.chrishammond.com/tag/dotnetnuke" target="_blank" rel="noreferrer noopener">Chris Hammond&#8217;s DNN posts</a></li>



<li><a href="https://dnncommunity.org/blogs" type="link" id="https://dnncommunity.org/blogs" target="_blank" rel="noreferrer noopener">DNN Community Blogs</a></li>



<li><a href="https://www.dnnsoftware.com/docs/developers/mvc-modules/mvc-module-development.html" type="link" id="https://www.dnnsoftware.com/docs/developers/mvc-modules/mvc-module-development.html" target="_blank" rel="noreferrer noopener">DNN MVC Module Development</a></li>
</ul>



<p class="wp-block-paragraph">While you&#8217;re here, check out DMC&#8217;s <a href="/services/application-development/web-application-development">Web Application Development</a> and <a href="/services/application-development/web-application-development/aspnet-and-aspnet-mvc">ASP.NET &amp; ASP.NET MVC Development</a> services so we can get started on your next DNN MVC module!</p>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://static.dmcinfo.com/blog/25071/6-easy-steps-to-get-started-with-mvc-module-development-in-dnn-8/">6 Easy Steps to Get Started with MVC Module Development in DNN 8</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 3:  Modules</title>
		<link>https://static.dmcinfo.com/blog/25145/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-3-modules/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Mon, 03 Oct 2016 14:56:43 +0000</pubDate>
				<category><![CDATA[PC Application Development]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[MS Visual Studio/.NET]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25145/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-3-modules/</guid>

					<description><![CDATA[<p>In Part 2 of this series, I introduced the Shell and the Bootstrapper components of a Prism application. The stage is set. The crew&#8217;s in place. It&#8217;s time for Lights! Camera! Action! But first, we need to hire some actors. Modules To quote the Prism documentation itself: A module is a logical collection of functionality [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25145/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-3-modules/">A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 3:  Modules</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In <a href="https://static.dmcinfo.com/latest-thinking/blog/id/9295/a-properly-pleasing-prism-primer--part-2-the-shell-and-bootstrapper">Part 2</a> of this series, I introduced the <strong>Shell</strong> and the <strong>Bootstrapper</strong> components of a Prism application. The stage is set. The crew&#8217;s in place. It&#8217;s time for Lights! Camera! Action! But first, we need to hire some actors.</p>



<h2 class="wp-block-heading" id="h-modules"><span style="color:#1F4D78;">Modules</span></h2>



<p class="wp-block-paragraph">To quote the Prism documentation itself:</p>



<p class="wp-block-paragraph"><em>A module is a logical collection of functionality and resources that is packaged in a way that can be separately developed, tested, deployed, and integrated into an application.</em></p>



<p class="wp-block-paragraph">All modules contain a central class responsible for initialization of the module and integration of it into the application. This class implements the <strong>IModule</strong> interface, which consists of one method:&nbsp;<strong>Initialize()</strong>. Typically, this method and a constructor are the only methods needed for this class, but I&#8217;ll share more on that in a bit.</p>



<p class="wp-block-paragraph">Before we start making our modules, we should probably decide how we want Prism to know where to find them. This is where the Module Catalog comes in.</p>



<h2 class="wp-block-heading" id="h-the-module-catalog"><span style="color:#1F4D78;">The Module Catalog</span></h2>



<p class="wp-block-paragraph">In a composite application, modules must be discovered and loaded at run time by the host application (the <strong>Shell</strong> in Prism). Prism accomplishes this through a module catalog which specifies the modules to load, when to load them and in what order. There are several choices for filling the module catalog:</p>



<ul class="wp-block-list">
<li>Registering modules in code</li>



<li>Registering modules in XAML</li>



<li>Registering modules in a configuration file</li>



<li>Discovering modules in a local directory on disk</li>



<li>Derive from ModuleCatalog class to create your own custom module catalog behavior</li>
</ul>



<p class="wp-block-paragraph">Which mechanism you use depends on the needs of your application&nbsp;(there&#8217;s also nothing stopping you from using more than one mechanism if you are so inclined). Each module catalog class implements the <strong>IModuleCatalog</strong> interface. For this application we will use directory discovery (via the <strong>DirectoryModuleCatalog</strong> class), but a brief description of the other methods follows.</p>



<h4 class="wp-block-heading" id="h-registering-modules-in-code"><span style="color:#1F4D78;">Registering Modules in Code</span></h4>



<p class="wp-block-paragraph"><span style="font-size:11.0pt;line-height:107%;
font-family:&quot;Calibri&quot;,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA">The <strong>ModuleCatalog</strong> class is the most basic <strong>IModuleCatalog</strong> implementation. It is used to programmatically register modules by specifying each module class type. You can also specify properties on each module such as the name, initialization mode, other module dependencies and the loading state. </span></p>



<p class="wp-block-paragraph"><span style="font-size:11.0pt;line-height:107%;
font-family:&quot;Calibri&quot;,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA">To register a module, call the <strong>AddModule() </strong>method of the <strong>ModuleCatalog</strong> class. This is typically done in an override of the <strong>Bootstrapper</strong> method <strong>ConfigureModuleCatalog()</strong>. With this approach, you can use conditional logic to determine which modules should be included in your application. The modules added in code are referenced by the application rather than being loaded at runtime like other methods. However, unless you want to provide a direct reference in your application to each module’s assembly, thereby giving the <strong>Shell</strong> project knowledge of what modules exist (ideally the <strong>Shell</strong> shouldn’t know anything about what modules are out there), you will have to use reflection in your <strong>Bootstrapper</strong> method to provide the fully qualified type name and location of the assembly that contains the module.</span></p>



<p class="wp-block-paragraph"><span style="font-size:11.0pt;line-height:107%;
font-family:&quot;Calibri&quot;,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA">Here&#8217;s an example of how you might register a module in code (note that it assumes your <strong>Shell</strong> project has a static reference to the module project):</span></p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>protected override void ConfigureModuleCatalog()
{
    var myModuleType = typeof(MyModule);
    Prism.Bootstrapper.ModuleCatalog.AddModule(
      new ModuleInfo()
      {
          ModuleName = myModuleType.Name,
          ModuleType = myModuleType.AssemblyQualifiedName,
          DependsOn = new Collection&lt;string>(new List&lt;string>()
          {
              "MyOtherModule",
              "MyServiceModule"
          })
      });
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">ConfigureModuleCatalog</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">myModuleType</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">typeof</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">MyModule</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #9CDCFE">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Bootstrapper</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">ModuleCatalog</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">AddModule</span><span style="color: #D4D4D4">(</span></span>
<span class="line"><span style="color: #D4D4D4">      </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">ModuleInfo</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">      {</span></span>
<span class="line"><span style="color: #D4D4D4">          </span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">myModuleType</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Name</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">          </span><span style="color: #9CDCFE">ModuleType</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">myModuleType</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">AssemblyQualifiedName</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">          </span><span style="color: #9CDCFE">DependsOn</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Collection</span><span style="color: #D4D4D4">&lt;</span><span style="color: #569CD6">string</span><span style="color: #D4D4D4">&gt;(</span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">List</span><span style="color: #D4D4D4">&lt;</span><span style="color: #569CD6">string</span><span style="color: #D4D4D4">&gt;()</span></span>
<span class="line"><span style="color: #D4D4D4">          {</span></span>
<span class="line"><span style="color: #D4D4D4">              </span><span style="color: #CE9178">&quot;MyOtherModule&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"><span style="color: #D4D4D4">              </span><span style="color: #CE9178">&quot;MyServiceModule&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">          })</span></span>
<span class="line"><span style="color: #D4D4D4">      });</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">In the above code, the <strong>DependsOn</strong> property can also be set in the attributes of the module class instead of here. The attributes are also where you set the name of the module referenced by <strong>myModuleType.Name</strong>.</p>



<h4 class="wp-block-heading" id="h-registering-modules-in-a-xaml-file"><span style="color:#1F4D78;">Registering Modules in a XAML File</span></h4>



<p class="wp-block-paragraph">Another option to declaratively define a module catalog is via a XAML file. Typically, you add the file as a resource to the <strong>Shell</strong> project. You then override the <strong>CreateModuleCatalog()</strong> method of your <strong>Bootstrapper </strong>and within that method call the <strong>CreateFromXaml()</strong> method of class <strong>Prism.Modularity.ModuleCatalog</strong>.</p>



<p class="wp-block-paragraph">The XAML might look something like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">XAML</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;!-- ModulesCatalog.xaml -->
&lt;Modularity:ModuleCatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                          xmlns:sys="clr-namespace:System;assembly=mscorlib"
                          xmlns:Modularity="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism">
    &lt;Modularity:ModuleInfoGroup InitializationMode="OnDemand">
        &lt;Modularity:ModuleInfo Ref="file://ModularityWithUnity.Desktop.MyOtherModule.dll" ModuleName="MyOtherModule" ModuleType="ModularityWithUnity.Desktop.MyOtherModule, ModularityWithUnity.Desktop.MyOtherModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
        &lt;Modularity:ModuleInfo Ref="file://ModularityWithUnity.Desktop.MyServiceModule.dll" ModuleName="MyServiceModule" ModuleType="ModularityWithUnity.Desktop.MyServiceModule, ModularityWithUnity.Desktop.MyServiceModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
        &lt;Modularity:ModuleInfo Ref="file://ModularityWithUnity.Desktop.MyModule.dll" ModuleName="MyModule" ModuleType="ModularityWithUnity.Desktop.MyModule, ModularityWithUnity.Desktop.MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
            &lt;Modularity:ModuleInfo.DependsOn>
                &lt;sys:String>MyOtherModule&lt;/sys:String>
                &lt;sys:String>MyServiceModule&lt;/sys:String>
            &lt;/Modularity:ModuleInfo.DependsOn>
        &lt;/Modularity:ModuleInfo>
    &lt;/Modularity:ModuleInfoGroup>
&lt;/Modularity:ModuleCatalog></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">&lt;!-- ModulesCatalog.xaml --&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">Modularity:ModuleCatalog</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">xmlns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">                          </span><span style="color: #9CDCFE">xmlns:x</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">                          </span><span style="color: #9CDCFE">xmlns:sys</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;clr-namespace:System;assembly=mscorlib&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">                          </span><span style="color: #9CDCFE">xmlns:Modularity</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Modularity:ModuleInfoGroup</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">InitializationMode</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;OnDemand&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Modularity:ModuleInfo</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Ref</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;file://ModularityWithUnity.Desktop.MyOtherModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyOtherModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ModuleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyOtherModule, ModularityWithUnity.Desktop.MyOtherModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Modularity:ModuleInfo</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Ref</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;file://ModularityWithUnity.Desktop.MyServiceModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyServiceModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ModuleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyServiceModule, ModularityWithUnity.Desktop.MyServiceModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Modularity:ModuleInfo</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Ref</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;file://ModularityWithUnity.Desktop.MyModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ModuleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyModule, ModularityWithUnity.Desktop.MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Modularity:ModuleInfo.DependsOn</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">sys:String</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">MyOtherModule</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">sys:String</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">sys:String</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">MyServiceModule</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">sys:String</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Modularity:ModuleInfo.DependsOn</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Modularity:ModuleInfo</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Modularity:ModuleInfoGroup</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Modularity:ModuleCatalog</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">Modules don&#8217;t have to be in a ModuleInfoGroup, but it allows for setting common properties for modules and is the only way to set module dependencies. In the Bootstrapper, you&#8217;d then have the following for ConfigureModuleCatalog():</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>protected override IModuleCatalog CreateModuleCatalog()
{
    return Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/PrismSample;component/ModulesCatalog.xaml", UriKind.Relative));
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">IModuleCatalog</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">CreateModuleCatalog</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Modularity</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">ModuleCatalog</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">CreateFromXaml</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Uri</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;/PrismSample;component/ModulesCatalog.xaml&quot;</span><span style="color: #D4D4D4">, </span><span style="color: #9CDCFE">UriKind</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Relative</span><span style="color: #D4D4D4">));</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<h4 class="wp-block-heading" id="h-registering-modules-in-a-configuration-file"><span style="color:#1F4D78;">Registering Modules in a Configuration File</span></h4>



<p class="wp-block-paragraph">Similar in idea to registering in a XAML file, this method has the added benefit of not requiring the application to be recompiled if you want to add and remove modules at runtime since the file is not compiled into the application. Setting attribute <strong><em>startupLoaded=&#8221;true&#8221;</em></strong> on a module will automatically load the module.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">XML</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;?xml version="1.0" encoding="utf-8" ?>
&lt;configuration>
  &lt;configSections>
    &lt;section name="modules" type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism"/>
  &lt;/configSections>
  &lt;modules>
    &lt;module assemblyFile="ModularityWithUnity.Desktop.MyOtherModule.dll" moduleType="ModularityWithUnity.Desktop.MyOtherModule, ModularityWithUnity.Desktop.MyOtherModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="MyOtherModule" startupLoaded="false" />
    &lt;module assemblyFile="ModularityWithUnity.Desktop.MyServiceModule.dll" moduleType="ModularityWithUnity.Desktop.MyServiceModule, ModularityWithUnity.Desktop.MyServiceModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="MyServiceModule" startupLoaded="false" />
    &lt;module assemblyFile="ModularityWithUnity.Desktop.MyModule.dll" moduleType="ModularityWithUnity.Desktop.MyModule, ModularityWithUnity.Desktop.MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="MyModule" startupLoaded="false">
      &lt;dependencies>
        &lt;dependency moduleName="MyOtherModule"/>
        &lt;dependency moduleName="MyServiceModule"/>
      &lt;/dependencies>
    &lt;/module>
    &lt;module assemblyFile="ModularityWithUnity.Desktop.MyAutoLoadModule.dll" moduleType="ModularityWithUnity.Desktop.MyAutoLoadModule, ModularityWithUnity.Desktop.MyAutoLoadModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="MyAutoLoadModule" startupLoaded="true" />
  &lt;/modules>
&lt;/configuration></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;?</span><span style="color: #569CD6">xml</span><span style="color: #9CDCFE"> version</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;1.0&quot;</span><span style="color: #9CDCFE"> encoding</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;utf-8&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">?&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">configuration</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">configSections</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">section</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">name</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;modules&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">type</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism&quot;</span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">configSections</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">modules</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">module</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">assemblyFile</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyOtherModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyOtherModule, ModularityWithUnity.Desktop.MyOtherModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyOtherModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">startupLoaded</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;false&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">module</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">assemblyFile</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyServiceModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyServiceModule, ModularityWithUnity.Desktop.MyServiceModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyServiceModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">startupLoaded</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;false&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">module</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">assemblyFile</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyModule, ModularityWithUnity.Desktop.MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">startupLoaded</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;false&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">      </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">dependencies</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">dependency</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyOtherModule&quot;</span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">dependency</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyServiceModule&quot;</span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">      </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">dependencies</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">module</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">module</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">assemblyFile</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyAutoLoadModule.dll&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;ModularityWithUnity.Desktop.MyAutoLoadModule, ModularityWithUnity.Desktop.MyAutoLoadModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;MyAutoLoadModule&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">startupLoaded</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;true&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">modules</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">configuration</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">To specify that the configuration file is the source of your module catalog, you would add the following code to the <strong>Bootstrapper</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>protected override IModuleCatalog CreateModuleCatalog()
{
    return new ConfigurationModuleCatalog();
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">IModuleCatalog</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">CreateModuleCatalog</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">ConfigurationModuleCatalog</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<h4 class="wp-block-heading" id="h-discovering-modules-in-a-local-directory-on-disk"><span style="color:#1F4D78;">Discovering Modules in a Local Directory on Disk</span></h4>



<p class="wp-block-paragraph">This is the method we will be using for this blog series. The module catalog scans the specified directory searching for assemblies defining each module in the application. This method requires the use of declarative attributes in the module classes to define the module names and any dependencies. (This is different from the other approaches where these attributes are defined as part of the catalog itself.) Aside from a mechanism to copy the module libraries to the catalog directory (typically accomplished by adding a post-build copy event to the module project), the only other thing needed is the following override in the <strong>Bootstrapper</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>protected override IModuleCatalog CreateModuleCatalog()
{
    // Use local directory as module catalog
    return new DirectoryModuleCatalog { ModulePath = "Modules" };
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">IModuleCatalog</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">CreateModuleCatalog</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    // Use local directory as module catalog</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">DirectoryModuleCatalog</span><span style="color: #D4D4D4"> { </span><span style="color: #9CDCFE">ModulePath</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;Modules&quot;</span><span style="color: #D4D4D4"> };</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">If we were using <strong>MEF</strong> instead of <strong>Unity</strong>, we wouldn&#8217;t override <strong>CreateModuleCatalog()</strong>. Instead we&#8217;d create a new instance of the <strong>DirectoryCatalog </strong>class and add that to the <strong>MEF AggregateCatalog</strong> as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>/// &lt;summary>
/// Imperatively add type registrations to MEF's Aggregate Catalog
/// &lt;/summary>
protected override void ConfigureAggregateCatalog()
{
    base.ConfigureAggregateCatalog();

    // Add Shell assembly
    this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));

    // Add module catalog
    var moduleCatalog = new DirectoryCatalog("Modules");
    this.AggregateCatalog.Catalogs.Add(moduleCatalog);
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">/// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">/// Imperatively add type registrations to MEF&apos;s Aggregate Catalog</span></span>
<span class="line"><span style="color: #6A9955">/// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">ConfigureAggregateCatalog</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">base</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">ConfigureAggregateCatalog</span><span style="color: #D4D4D4">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">    // Add Shell assembly</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">AggregateCatalog</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Catalogs</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Add</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">AssemblyCatalog</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">typeof</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">Bootstrapper</span><span style="color: #D4D4D4">).</span><span style="color: #9CDCFE">Assembly</span><span style="color: #D4D4D4">));</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">    // Add module catalog</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">moduleCatalog</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">DirectoryCatalog</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Modules&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">AggregateCatalog</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Catalogs</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Add</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">moduleCatalog</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-create-the-modules"><span style="color:#1F4D78;">Create the Modules</span></h2>



<p class="wp-block-paragraph">We&#8217;ve defined our module catalog, so it&#8217;s time to create the modules. We start by adding a folder to our solution tree called <strong>Modules</strong>. (This step isn&#8217;t strictly necessary, but I find it nice for organization of the assemblies. Your mileage may vary.) Right-click on the <strong>Modules </strong>folder and select <strong>Add→New Project&#8230;</strong>. Name the class library <strong>NavigationMenu</strong> and click <strong>OK</strong>.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/PrismNavigationMenuProject_1.png" alt="Prism Module Library for Navigation Menu" title="New Navigation Menu Module Project"/></figure>



<p class="wp-block-paragraph">Delete the <strong>Class1.cs</strong> file that is created. Next we add the <strong>Prism </strong>and <strong>Unity</strong> libraries to our module. This process is identical to what we did with the <strong>Shell </strong>project. Right click on the <strong>NavigationMenu </strong>project and select <strong>Manage NuGet Packages&#8230;</strong>. Click on the <strong>Browse</strong> tab and type <strong>prism.unity</strong> in the search box. Select the <strong>Prism.Unity</strong> package and install it.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Prism-Sample-Navigation-Menu-NuGet.png" alt="Adding Prism and Unity Libraries via NuGet" title="Adding Prism and Unity Libraries via NuGet"/></figure>



<p class="wp-block-paragraph">Now is as good of a time as any to also add a reference to our <strong>Infrastructure </strong>assembly. We will define all our module names as constants in a static class as part of <strong>Infrastructure</strong>. After adding a reference to the <strong>Infrastructure </strong>project in our module, right click on the <strong>Constants</strong> folder in the project and select <strong>Add→New From Template→Class</strong>. In the popup box type <strong>ModuleNames</strong> and click <strong>OK</strong>. Add a constant for the Navigation Menu module name to this class as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>namespace Infrastructure.Constants
{
    public static class ModuleNames
    {
        public const string NAVIGATION_MENU = "NavigationMenu";
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Infrastructure</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Constants</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">static</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">ModuleNames</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">NAVIGATION_MENU</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;NavigationMenu&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">The next step to is to create the module initialization file, which defines the module attributes and registers the interfaces and classes the module implements. Right click on the <strong>NavigationMenuModule </strong>project and select <strong>Add→New From Template→Class</strong>. In the popup box type <strong>NavigationMenuModule</strong> and click <strong>OK</strong>. This new class needs to implement the <strong>IModule</strong> interface, which consists of one method called <strong>Initialize()</strong>. The class also needs a declarative <strong>ModuleAttribute </strong>applied that defines at least the <strong>ModuleName </strong>property. In this case we set the property to the constant we defined above as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using Infrastructure.Constants;
using Prism.Modularity;

namespace NavigationMenu
{
    /// &lt;summary>
    /// Register components of module with Unity/Prism
    /// &lt;/summary>
    &#91;Module(ModuleName = ModuleNames.NAVIGATION_MENU)&#93;
    public class NavigationMenuModule : IModule
    {
        public void Initialize()
        {
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Infrastructure</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Constants</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Modularity</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenu</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">    /// Register components of module with Unity/Prism</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    &#91;</span><span style="color: #4EC9B0">Module</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">ModuleNames</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">NAVIGATION_MENU</span><span style="color: #D4D4D4">)&#93;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenuModule</span><span style="color: #D4D4D4"> : </span><span style="color: #4EC9B0">IModule</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">Initialize</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">We still have to copy the module library to our catalog folder. To this we open the properties of our <strong>NavigationMenu </strong>project and add the following post-build event:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">BAT (Batchfile)</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>robocopy "$(TargetDir)\" "$(SolutionDir)PrismSample\$(OutDir)Modules" NavigationMenu.dll
if %errorlevel% geq 8 exit 1
exit 0</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">robocopy</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;$(TargetDir)\&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;$(SolutionDir)PrismSample\$(OutDir)Modules&quot;</span><span style="color: #D4D4D4"> NavigationMenu.dll</span></span>
<span class="line"><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">%errorlevel%</span><span style="color: #D4D4D4"> geq </span><span style="color: #B5CEA8">8</span><span style="color: #D4D4D4"> </span><span style="color: #C586C0">exit</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">1</span></span>
<span class="line"><span style="color: #C586C0">exit</span><span style="color: #D4D4D4"> </span><span style="color: #B5CEA8">0</span></span></code></pre></div>



<p class="wp-block-paragraph">(Note:&nbsp; Instead of <strong>robocopy </strong>(i.e. Robust Copy) some people might use <strong>xcopy </strong>here. The problem with <strong>xcopy </strong>is that Microsoft officially deprecated it a while ago. Additionally, <strong>robocopy </strong>has nicer error handling. I have found, however, that sometimes <strong>robocopy </strong>seems to hang for a while when building the application in Visual Studio, particularly when many modules are built. I&#8217;ve yet to figure out why, but it might be that <strong>robocopy </strong>is slow to release the directory after it finishes copying, so when the next module tries to copy to the directory it can&#8217;t get access. Occasionally, <strong>robocopy </strong>will even time out and the build will fail. Building again usually cleans up the issue.)</p>



<p class="wp-block-paragraph">The final step to getting our module to load is to ensure the solution builds this module before it builds the shell. Right-click on the <strong>PrismSample </strong>solution in Solution Explorer and select <strong>Project Dependencies&#8230;</strong>. Select the <strong>PrismSample </strong>project under the <strong>Projects:</strong> drop-down and you should see that <strong>Infrastructure </strong>is already checked. Check <strong>NavigationMenu </strong>as well. If you look at the Build Order tab you should see <strong>Infrastructure </strong>listed first in the order and <strong>Prism Sample</strong> listed last.</p>



<p class="wp-block-paragraph">Following a similar process to above that we used with <strong>NavigationMenu</strong>, we can add the <strong>TopRegion</strong>, <strong>MiddleRegion</strong>, and <strong>BottomRegion </strong>modules as well. (As mentioned in the previous part of this series in regards to the shell regions, a real application would have more descriptive names for what the other three modules actually do.) Our application will run, but since we haven&#8217;t implemented any actual functionality in our modules, it does nothing other than display a logo at this point. For the final section of this part of the series, I&#8217;ll create a simple menu view and show how to register it with a region for display.</p>



<h2 class="wp-block-heading" id="h-view-composition-discovery"><span style="color:#1F4D78;">View Composition (Discovery)</span></h2>



<p class="wp-block-paragraph">View composition is the construction of a view. There are two ways to create and display a view in a region:</p>



<ul class="wp-block-list">
<li>Automatically through discovery</li>



<li>Programmatically through injection</li>
</ul>



<p class="wp-block-paragraph">Discovery sets up a relationship in the <strong>RegionViewRegistry </strong>between a region&#8217;s name and a type of view. When a region is created, all view types associated with the region are automatically instantiated and their corresponding views loaded. With this method there is no explicit control over when views are loaded and displayed.</p>



<p class="wp-block-paragraph">Injection involves obtaining a reference to a region and then programmatically injecting views into it. This gives you full control over when views are loaded, removed, and displayed. However, you cannot add a view to a region that has not been created yet.</p>



<p class="wp-block-paragraph">For this part of the blog series, we concern ourselves only with discovery. We&#8217;ll come back to injection in a later part of this series when we introduce the <strong>View Navigation AP</strong>I.</p>



<p class="wp-block-paragraph">We start by creating the view for our menu by adding a new WPF User Control to our <strong>NavigationMenu </strong>project:</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Prism-Sample-Navigation-Menu-View.png" alt="Adding WPF User Control for Navigation Menu View" title="Adding WPF User Control for Navigation Menu View"/></figure>



<p class="wp-block-paragraph">(Note: After creating the user control, we&#8217;ll likely need to add a reference to <strong>System.Xaml</strong> to our project.)</p>



<p class="wp-block-paragraph">At this point it makes sense to create a Resource Dictionary to hold the control styles common to the various views in our application. We&#8217;ll add a <strong>SharedResources</strong> folder to the <strong>Infrastructure </strong>project and to that folder we add a new resource dictionary. Since our <strong>Infrastructure </strong>project is a Class Library, however,&nbsp;we can&#8217;t add the file through the convenience of the <strong>Add New Item</strong> dialog, so we&#8217;ll have to do it manually. (Or if you use <strong>Resharper</strong> like I do, you can select the &#8220;<strong>More&#8230;</strong>&#8221; menu from the <strong>Add New From Template</strong> menu and it will give you the option to add one there.) We&#8217;ll name the resource dictionary <strong>ResourceDictionary.xaml</strong>, and once we add it, we&#8217;ll also add a reference to the .NET <strong>PresentationFramework</strong> library to our <strong>Infrastructure </strong>project so that the resource dictionary is supported. For now our resource dictionary is pretty straightforward and looks like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">XAML</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=mscorlib">

    &lt;!--Fonts-->
    &lt;system:Double x:Key="NormalFontSize">26&lt;/system:Double>
    &lt;FontFamily x:Key="NormalFont">Century Gothic&lt;/FontFamily>

    &lt;!--Colors-->
    &lt;Color x:Key="NormalFontColor">#FF5F5F5F&lt;/Color>

    &lt;!--Brushes-->
    &lt;SolidColorBrush x:Key="NormalForegroundBrush" Color="{StaticResource NormalFontColor}" />

    &lt;!--TextBlocks-->
    &lt;Style x:Key="NormalTextBlockStyle" TargetType="TextBlock">
        &lt;Setter Property="FontFamily" Value="{StaticResource NormalFont}" />
        &lt;Setter Property="Foreground" Value="{StaticResource NormalForegroundBrush}" />
        &lt;Setter Property="FontSize" Value="{StaticResource NormalFontSize}" />
    &lt;/Style>

    &lt;!--Controls-->
    &lt;Style x:Key="BaseControlStyle" TargetType="Control">
        &lt;Setter Property="FontFamily" Value="{StaticResource NormalFont}" />
        &lt;Setter Property="Foreground" Value="{StaticResource NormalForegroundBrush}" />
        &lt;Setter Property="FontSize" Value="{StaticResource NormalFontSize}" />
    &lt;/Style>
    
&lt;/ResourceDictionary></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">ResourceDictionary</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">xmlns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #9CDCFE">xmlns:x</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #9CDCFE">xmlns:system</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;clr-namespace:System;assembly=mscorlib&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #6A9955">&lt;!--Fonts--&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">system:Double</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Key</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;NormalFontSize&quot;</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">26</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">system:Double</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">FontFamily</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Key</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;NormalFont&quot;</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">Century Gothic</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">FontFamily</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #6A9955">&lt;!--Colors--&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Color</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Key</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;NormalFontColor&quot;</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">#FF5F5F5F</span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Color</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #6A9955">&lt;!--Brushes--&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">SolidColorBrush</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Key</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;NormalForegroundBrush&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Color</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalFontColor}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #6A9955">&lt;!--TextBlocks--&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Style</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Key</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;NormalTextBlockStyle&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">TargetType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;TextBlock&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;FontFamily&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalFont}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Foreground&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalForegroundBrush}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;FontSize&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalFontSize}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Style</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #6A9955">&lt;!--Controls--&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Style</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Key</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;BaseControlStyle&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">TargetType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Control&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;FontFamily&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalFont}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Foreground&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalForegroundBrush}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;FontSize&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalFontSize}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Style</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">ResourceDictionary</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">In order for this to build, we&#8217;ll need to add references to the <strong>PresentationCore</strong>, <strong>WindowsBase </strong>and <strong>System.Xaml</strong> libraries to our <strong>Infrastructure </strong>project.</p>



<p class="wp-block-paragraph">And while we&#8217;re add it, this would be a good point to add localizable strings to that project as well (though, this application will never need to worry about it). We&#8217;ll add a new folder called <strong>Strings</strong> as a subfolder to our <strong>SharedResources </strong>folder and to that new folder add a new <strong>Resources File</strong> with a <strong>Public </strong>access modifier we&#8217;ll call <strong>Text.resx</strong>.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Prism-Sample-Text-Resource.png" alt="Adding a New Text Resource File" title="Adding a New Text Resource File"/></figure>



<p class="wp-block-paragraph">Going back to our <strong>NavigationMenu.xaml</strong> file, we will implement a fairly simple menu as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">XAML</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;UserControl x:Class="NavigationMenu.NavigationMenu"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:str="clr-namespace:Infrastructure.SharedResources.Strings;assembly=Infrastructure"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="800" d:DesignWidth="300">

    &lt;UserControl.Resources>
        &lt;ResourceDictionary>
            &lt;ResourceDictionary.MergedDictionaries>
                &lt;ResourceDictionary Source="/Infrastructure;component/SharedResources/ResourceDictionary.xaml" />
            &lt;/ResourceDictionary.MergedDictionaries>
        &lt;/ResourceDictionary>
    &lt;/UserControl.Resources>

    &lt;Grid>
        &lt;StackPanel Background="White">

            &lt;StackPanel.Resources>
                &lt;Style TargetType="Button" BasedOn="{StaticResource BaseControlStyle}">
                    &lt;Setter Property="Background" Value="Transparent" />
                    &lt;Setter Property="Template">
                        &lt;Setter.Value>
                            &lt;ControlTemplate TargetType="Button">
                                &lt;Border Padding="10" Background="{TemplateBinding Background}">
                                    &lt;ContentPresenter VerticalAlignment="Center" />
                                &lt;/Border>
                            &lt;/ControlTemplate>
                        &lt;/Setter.Value>
                    &lt;/Setter>
                    &lt;Style.Triggers>
                        &lt;Trigger Property="IsMouseOver" Value="True">
                            &lt;Setter Property="Foreground" Value="#2D82B9" />
                        &lt;/Trigger>
                        &lt;Trigger Property="IsPressed" Value="True">
                            &lt;Setter Property="Foreground" Value="{StaticResource NormalForegroundBrush}" />
                            &lt;Setter Property="Background" Value="LightGray" />
                        &lt;/Trigger>
                    &lt;/Style.Triggers>
                &lt;/Style>
            &lt;/StackPanel.Resources>

            &lt;Button Content="{x:Static str:Text.About}" />
            &lt;Button Content="{x:Static str:Text.CreateError}" />
            &lt;Button Content="{x:Static str:Text.Exit}" />
        &lt;/StackPanel>
    &lt;/Grid>
&lt;/UserControl></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">UserControl</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Class</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;NavigationMenu.NavigationMenu&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns:x</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns:mc</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns:str</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;clr-namespace:Infrastructure.SharedResources.Strings;assembly=Infrastructure&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns:d</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">mc:Ignorable</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;d&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">d:DesignHeight</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;800&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">d:DesignWidth</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;300&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">UserControl.Resources</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ResourceDictionary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ResourceDictionary.MergedDictionaries</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ResourceDictionary</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Source</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;/Infrastructure;component/SharedResources/ResourceDictionary.xaml&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">ResourceDictionary.MergedDictionaries</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">ResourceDictionary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">UserControl.Resources</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">StackPanel</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Background</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;White&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">StackPanel.Resources</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Style</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">TargetType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Button&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">BasedOn</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource BaseControlStyle}&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Background&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Transparent&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Template&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter.Value</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ControlTemplate</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">TargetType</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Button&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Border</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Padding</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;10&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Background</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{TemplateBinding Background}&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                                    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ContentPresenter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">VerticalAlignment</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Center&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                                </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Border</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                            </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">ControlTemplate</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Setter.Value</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Setter</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Style.Triggers</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Trigger</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;IsMouseOver&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;True&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Foreground&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;#2D82B9&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Trigger</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Trigger</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;IsPressed&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;True&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Foreground&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{StaticResource NormalForegroundBrush}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Setter</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Property</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Background&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Value</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;LightGray&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Trigger</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Style.Triggers</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Style</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">StackPanel.Resources</span><span style="color: #808080">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Button</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Content</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static str:Text.About}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Button</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Content</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static str:Text.CreateError}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Button</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Content</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static str:Text.Exit}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">StackPanel</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">UserControl</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">Finally, in <strong>NavigationMenuModule.cs</strong> we will register our module via the <strong>Module </strong>declarative attribute and then in the <strong>Initialize()</strong> method of the <strong>IModule </strong>interface we register this view with the region we&#8217;ve defined for it:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using Infrastructure.Constants;
using Prism.Modularity;
using Prism.Regions;

namespace NavigationMenu
{
    /// &lt;summary>
    /// Register components of module with Unity/Prism
    /// &lt;/summary>
    &#91;Module(ModuleName = ModuleNames.NAVIGATION_MENU)&#93;
    public class NavigationMenuModule : IModule
    {
        private readonly IRegionManager _regionManager;

        public NavigationMenuModule(IRegionManager regionManager)
        {
            this._regionManager = regionManager;
        }

        public void Initialize()
        {
            this._regionManager.RegisterViewWithRegion(RegionNames.MENU_REGION, typeof(NavigationMenu));
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Infrastructure</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Constants</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Modularity</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Regions</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenu</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">    /// Register components of module with Unity/Prism</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    &#91;</span><span style="color: #4EC9B0">Module</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">ModuleNames</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">NAVIGATION_MENU</span><span style="color: #D4D4D4">)&#93;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenuModule</span><span style="color: #D4D4D4"> : </span><span style="color: #4EC9B0">IModule</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">private</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">readonly</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">IRegionManager</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">_regionManager</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">NavigationMenuModule</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">IRegionManager</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">regionManager</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">_regionManager</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">regionManager</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">Initialize</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">_regionManager</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">RegisterViewWithRegion</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">RegionNames</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">MENU_REGION</span><span style="color: #D4D4D4">, </span><span style="color: #569CD6">typeof</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">NavigationMenu</span><span style="color: #D4D4D4">));</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">For <strong>MEF</strong>, registration is a bit different. We first need to add the <strong>[Export] </strong>attribute to our <strong>NavigationMenu.xaml.cs</strong> file as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using System.ComponentModel.Composition;
using System.Windows.Controls;

namespace NavigationMenu
{
    /// &lt;summary>
    /// Interaction logic for NavigationMenu.xaml
    /// &lt;/summary>
    &#91;Export&#93;
    public partial class NavigationMenu : UserControl
    {
        public NavigationMenu()
        {
            this.InitializeComponent();
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">ComponentModel</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Composition</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Windows</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Controls</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenu</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">    /// Interaction logic for NavigationMenu.xaml</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    &#91;</span><span style="color: #4EC9B0">Export</span><span style="color: #D4D4D4">&#93;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">partial</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenu</span><span style="color: #D4D4D4"> : </span><span style="color: #4EC9B0">UserControl</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">NavigationMenu</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">InitializeComponent</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">And then in our module file we register the module using the <strong>Module </strong>attribute as we did in <strong>Unity</strong>, but we also have to add a <strong>ModuleExport </strong>attribute for the module itself, and declare the constructor as an <strong>ImportingConstructor </strong>so that the region manager can be set through dependency injection:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using System.ComponentModel.Composition;
using Infrastructure.Constants;
using Prism.Mef.Modularity;
using Prism.Modularity;
using Prism.Regions;

namespace NavigationMenu
{
    /// &lt;summary>
    /// Register components of module with MEF/Prism
    /// &lt;/summary>
    &#91;Module(ModuleName = ModuleNames.NAVIGATION_MENU)&#93;
    &#91;ModuleExport(typeof(NavigationMenuModule), InitializationMode = InitializationMode.WhenAvailable)&#93;
    public class NavigationMenuModule : IModule
    {
        private readonly IRegionManager _regionManager;

        &#91;ImportingConstructor&#93;
        public NavigationMenuModule(IRegionManager regionManager)
        {
            this._regionManager = regionManager;
        }

        public void Initialize()
        {
            this._regionManager.RegisterViewWithRegion(RegionNames.MENU_REGION, typeof(NavigationMenu));
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">ComponentModel</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Composition</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Infrastructure</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Constants</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Mef</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Modularity</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Modularity</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Regions</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenu</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">    /// Register components of module with MEF/Prism</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    &#91;</span><span style="color: #4EC9B0">Module</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">ModuleName</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">ModuleNames</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">NAVIGATION_MENU</span><span style="color: #D4D4D4">)&#93;</span></span>
<span class="line"><span style="color: #D4D4D4">    &#91;</span><span style="color: #4EC9B0">ModuleExport</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">typeof</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">NavigationMenuModule</span><span style="color: #D4D4D4">), </span><span style="color: #9CDCFE">InitializationMode</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">InitializationMode</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">WhenAvailable</span><span style="color: #D4D4D4">)&#93;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">NavigationMenuModule</span><span style="color: #D4D4D4"> : </span><span style="color: #4EC9B0">IModule</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">private</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">readonly</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">IRegionManager</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">_regionManager</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">        &#91;</span><span style="color: #4EC9B0">ImportingConstructor</span><span style="color: #D4D4D4">&#93;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">NavigationMenuModule</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">IRegionManager</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">regionManager</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">_regionManager</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">regionManager</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">Initialize</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">_regionManager</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">RegisterViewWithRegion</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">RegionNames</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">MENU_REGION</span><span style="color: #D4D4D4">, </span><span style="color: #569CD6">typeof</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">NavigationMenu</span><span style="color: #D4D4D4">));</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">If we build the application, we now see our menu has populated the region on the left-hand side. (The other three modules have also been added with place-holder views.) Of course, it doesn&#8217;t do anything at this point, but we will shortly rectify that in <a href="https://static.dmcinfo.com/latest-thinking/blog">Part 4:&nbsp; Intermodule Communication (coming soon)</a>.</p>



<p class="wp-block-paragraph">&nbsp;</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Prism-Unity-WPF-Application-Shell-Part-3.png" alt="WPF Prism Application Shell Window (Unity)"/></figure>



<p class="wp-block-paragraph">The Unity-based solution files and source code for this part can be downloaded by clicking below</p>



<div class="wp-block-file"><a id="wp-block-file--media-c2fe66ee-944a-4b3d-bac3-8e5d6b5898dc" href="https://static.dmcinfo.com/wp-content/uploads/2025/06/PrismSampleUnity-Part-3.zip">PrismSampleUnity &#8212; Part 3</a><a href="https://static.dmcinfo.com/wp-content/uploads/2025/06/PrismSampleUnity-Part-3.zip" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-c2fe66ee-944a-4b3d-bac3-8e5d6b5898dc">Download</a></div>



<p class="wp-block-paragraph">The MEF-based solution files and source code for this part can be downloaded by clicking below</p>



<div class="wp-block-file"><a id="wp-block-file--media-09879d29-3086-46fc-904d-3bc25ae1ce01" href="https://static.dmcinfo.com/wp-content/uploads/2025/06/PrismSampleMef-Part-3.zip">PrismSampleMef &#8212; Part 3</a><a href="https://static.dmcinfo.com/wp-content/uploads/2025/06/PrismSampleMef-Part-3.zip" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-09879d29-3086-46fc-904d-3bc25ae1ce01">Download</a></div>



<h2 class="wp-block-heading" id="h-a-properly-pleasing-prism-primer-the-parts">A Properly Pleasing Prism Primer &#8211; The Parts:</h2>



<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/latest-thinking/blog/id/9282/a-properly-pleasing-prism-primer--part-1-an-introduction">Part 1:&nbsp; An Introduction</a><br>
<a href="https://static.dmcinfo.com/latest-thinking/blog/id/9295/a-properly-pleasing-prism-primer--part-2-the-shell">Part 2:&nbsp; The Shell and Bootstrapper</a><br>
<a href="https://static.dmcinfo.com/latest-thinking/blog/id/9298/a-properly-pleasing-prism-primer--part-3-modules">Part 3:&nbsp; Modules</a><br>
<a href="https://static.dmcinfo.com/latest-thinking/blog">Part 4:&nbsp; Intermodule Communication (Coming soon)</a></p>



<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/latest-thinking/blog/articletype/categoryview/categoryid/136/c-net-application-development">Learn more about DMC&#8217;s .NET application development services.</a></p>
<p>The post <a href="https://static.dmcinfo.com/blog/25145/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-3-modules/">A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 3:  Modules</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 2:  The Shell and Bootstrapper</title>
		<link>https://static.dmcinfo.com/blog/25160/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-2-the-shell-and-bootstrapper/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Wed, 28 Sep 2016 16:23:53 +0000</pubDate>
				<category><![CDATA[PC Application Development]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[MS Visual Studio/.NET]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25160/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-2-the-shell-and-bootstrapper/</guid>

					<description><![CDATA[<p>In Part 1 of this series, I gave a quick summary of what Prism is, and when and why you would want to use it. The remaining parts of this series will address&#160;the &#8220;how&#8221; of using it. Since this series is largely an overview,&#160;I won&#8217;t cover everything you can possibly do under Prism. And since [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25160/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-2-the-shell-and-bootstrapper/">A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 2:  The Shell and Bootstrapper</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In <a href="/latest-thinking/blog/id/9282/a-properly-pleasing-prism-primer--part-1-an-introduction">Part 1</a> of this series, I gave a quick summary of what Prism is, and when and why you would want to use it. The remaining parts of this series will address&nbsp;the &#8220;how&#8221; of using it. Since this series is largely an overview,&nbsp;I won&#8217;t cover everything you can possibly do under Prism. And since Prism is designed so that the programmer can pick and choose what functionality they need, not everything I cover here will be relevant to all applications. However, the goal is that this series will be a good jumping-off point for your own Prism application development. Part 2 will cover two components you&#8217;ll find in every Prism application:&nbsp; the Shell and the Bootstrapper.</p>



<h2 class="wp-block-heading" id="h-the-shell">The Shell</h2>



<p class="wp-block-paragraph">Composite applications are architected such that individual parts of the application can be developed, tested, and modified independent from other parts. If you think of the application as a painting, the shell is the canvas, a container that integrates everything together in a coherent whole. It is essentially the “application” part of the composite application. The XAML file in the shell consists of one or more regions, which are named logical placeholders into which views are injected. &nbsp;Each region is attached to a common container control such as a ContentControl, ItemsControl, ListBox, or TabControl. The shell we’ll be using for this sample application will consist of four regions each attached to a ContentControl.</p>



<p class="wp-block-paragraph">Start by opening Visual Studio and selecting the New Project dialog from the file menu. Create a WPF Application.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Shell.png" alt="New Prism WPF Application Solution" title="New Prism WPF Application Solution"/></figure>



<p class="wp-block-paragraph">Click OK to create the project and solution. Though not strictly necessary, I like to rename the automatically generated MainWindow class to Shell due to convention.</p>



<p class="wp-block-paragraph">Next, we need to create an Infrastructure project as a class library. If the Shell is our canvas, the Infrastructure project is the palette.&nbsp;It holds all classes, resources, and constants that will be shared between the Shell and the various modules, as well as all the interfaces for the shared services.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Infrastructure.png" alt="New Infrastructure Project" title="New Infrastructure Project"/></figure>



<p class="wp-block-paragraph">Delete any classes created and add a reference to this project to your Shell project. Next, add a folder called &#8220;Constants&#8221; to the Infrastructure project. To this new folder add a new public static class called &#8220;RegionNames&#8221; and add the constants shown below. If this were a real application rather than an instructive one, the naming conventions for the regions would probably reflect the functional purpose of the injected modules for each region.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>namespace Infrastructure.Constants
{
    public static class RegionNames
    {
        public const string MENU_REGION = "MenuRegion";
        public const string SHELL_BOTTOM_REGION = "ShellBottomRegion";
        public const string SHELL_MIDDLE_REGION = "ShellMiddleRegion";
        public const string SHELL_TOP_REGION = "ShellTopRegion";
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Infrastructure</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Constants</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">static</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">RegionNames</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">MENU_REGION</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;MenuRegion&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">SHELL_BOTTOM_REGION</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;ShellBottomRegion&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">SHELL_MIDDLE_REGION</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;ShellMiddleRegion&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">string</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">SHELL_TOP_REGION</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;ShellTopRegion&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">Now we add the Prism libraries to our Shell. Right click on the PrismSample project and select &#8220;Manage NuGet Packages&#8230;&#8221; Click on the &#8220;Browse&#8221; tab and type &#8220;prism.unity&#8221; in the search box. Select the &#8220;Prism.Unity&#8221; package and install it.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/PrismUnity.png" alt="Adding Prism and Unity Libraries via NuGet" title="Adding Prism and Unity Libraries via NuGet"/></figure>



<p class="wp-block-paragraph">Finally, we implement the Shell XAML. Our layout will be pretty straightforward with a logo in the upper left corner, the menu region below that, and the other three regions taking up the right side.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">XAML</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;Window x:Class="PrismSample.Shell"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:prism="http://www.codeplex.com/prism"
        xmlns:constants="clr-namespace:Infrastructure.Constants;assembly=Infrastructure"
        mc:Ignorable="d"
        Title="Prism Sample Application" Height="900" Width="1600" Icon="Resources/DMC Wheel Transparent Background.ico">
    &lt;Grid>
        &lt;Grid.ColumnDefinitions>
            &lt;ColumnDefinition Width="Auto" />
            &lt;ColumnDefinition />
        &lt;/Grid.ColumnDefinitions>
        &lt;Grid Grid.Column="0" Margin="50, 25" >
            &lt;Grid.RowDefinitions>
                &lt;RowDefinition Height="Auto" />
                &lt;RowDefinition />
            &lt;/Grid.RowDefinitions>
            &lt;Image Grid.Row="0" Margin="10,20" Source="Resources/Small_jpg.jpg" />
            &lt;ContentControl Grid.Row="1" prism:RegionManager.RegionName="{x:Static constants:RegionNames.MENU_REGION}" />
        &lt;/Grid>
        &lt;Grid Grid.Column="1" Background="#FFE7E7E7">
            &lt;Grid.RowDefinitions>
                &lt;RowDefinition />
                &lt;RowDefinition />
                &lt;RowDefinition />
            &lt;/Grid.RowDefinitions>
            &lt;ContentControl Margin="30, 30, 30, 0" Grid.Row="0" prism:RegionManager.RegionName="{x:Static constants:RegionNames.SHELL_TOP_REGION}" />
            &lt;ContentControl Margin="30, 15" Grid.Row="1" prism:RegionManager.RegionName="{x:Static constants:RegionNames.SHELL_MIDDLE_REGION}" />
            &lt;ContentControl Margin="30, 0, 30, 30" Grid.Row="2" prism:RegionManager.RegionName="{x:Static constants:RegionNames.SHELL_BOTTOM_REGION}" />
        &lt;/Grid>
    &lt;/Grid>
&lt;/Window></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">Window</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Class</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;PrismSample.Shell&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">xmlns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">xmlns:x</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">xmlns:d</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">xmlns:mc</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">xmlns:prism</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://www.codeplex.com/prism&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">xmlns:constants</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;clr-namespace:Infrastructure.Constants;assembly=Infrastructure&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">mc:Ignorable</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;d&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">Title</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Prism Sample Application&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Height</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;900&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Width</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;1600&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Icon</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Resources/DMC Wheel Transparent Background.ico&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid.ColumnDefinitions</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ColumnDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Width</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Auto&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ColumnDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid.ColumnDefinitions</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Column</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;0&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Margin</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;50, 25&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid.RowDefinitions</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">RowDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Height</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Auto&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">RowDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid.RowDefinitions</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Image</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Row</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;0&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Margin</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;10,20&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Source</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;Resources/Small_jpg.jpg&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ContentControl</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Row</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;1&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">prism:RegionManager.RegionName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static constants:RegionNames.MENU_REGION}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Column</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;1&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Background</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;#FFE7E7E7&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Grid.RowDefinitions</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">RowDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">RowDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">RowDefinition</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid.RowDefinitions</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ContentControl</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Margin</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;30, 30, 30, 0&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Row</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;0&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">prism:RegionManager.RegionName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static constants:RegionNames.SHELL_TOP_REGION}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ContentControl</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Margin</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;30, 15&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Row</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;1&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">prism:RegionManager.RegionName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static constants:RegionNames.SHELL_MIDDLE_REGION}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">ContentControl</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Margin</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;30, 0, 30, 30&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Grid.Row</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;2&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">prism:RegionManager.RegionName</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;{x:Static constants:RegionNames.SHELL_BOTTOM_REGION}&quot;</span><span style="color: #D4D4D4"> </span><span style="color: #808080">/&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Grid</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Window</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">If we were to try to execute our program now, we&#8217;d throw an exception indicating a missing service location provider. Prism is designed that when it needs to access a component of the application (in this case the RegionManager) it doesn&#8217;t initialize the component directly but instead delegates this task to a ServiceLocator. So how do we let Prism know what ServiceLocator to use? That&#8217;s where the next component of our application comes in.</p>



<h2 class="wp-block-heading" id="h-the-bootstrapper">The Bootstrapper</h2>



<p class="wp-block-paragraph">If the Shell is the canvas, the Infrastructure project is the palette, the modules are the images to paint, and Prism is the paintbrush, that would make the Bootstrapper the medium of this tortured artistic metaphor. The Bootstrapper connects the Shell to the Prism services and the Dependency Injection container. Unique for each application, it typically inherits from the abstract classes UnityBootstrapper or MefBootstrapper, depending upon DI container used. (If using a different DI container from either Unity or MEF, there is a base abstract bootstrapper class from which all bootstrap classes inherit. The developer would create their own class which inherits that base class and customize it for that particular DI container.) Since we are using Unity for our DI, we inherit from UnityBootstrapper for our class, thereby letting Prism do most of the difficult work for us.</p>



<p class="wp-block-paragraph">The first thing we need to do once we&#8217;ve created our Bootstrapper is override the CreateShell() method. CreateShell() lets you specify the top-level window for a Prism application. You can either create the shell object yourself, or let the ServiceLocator do it. We’ll opt for the latter.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>protected override DependencyObject CreateShell()
{
    return ServiceLocator.Current.GetInstance&lt;Shell>();
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">DependencyObject</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">CreateShell</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ServiceLocator</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Current</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">GetInstance</span><span style="color: #D4D4D4">&lt;</span><span style="color: #4EC9B0">Shell</span><span style="color: #D4D4D4">&gt;();</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">Next, we override InitializeShell(). InitializeShell() is where you run any initialization steps you need to ensure the Shell is ready to be displayed. After that, you set the Shell as the application’s main window and show it.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>protected override void InitializeShell()
{
    Application.Current.MainWindow = (Shell)this.Shell;
    Application.Current.MainWindow.Show();
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">InitializeShell</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #9CDCFE">Application</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Current</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">MainWindow</span><span style="color: #D4D4D4"> = (</span><span style="color: #4EC9B0">Shell</span><span style="color: #D4D4D4">)</span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Shell</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #9CDCFE">Application</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Current</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">MainWindow</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Show</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">This is all we have to do with the Bootstrapper for now. We will be returning to it frequently over the course of this series. Here&#8217;s the complete class.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using System.Windows;
using Microsoft.Practices.ServiceLocation;
using Prism.Unity;

namespace PrismSample
{
    /// &lt;summary>
    /// Initializes Prism/Unity components and services
    /// &lt;/summary>
    public class Bootstrapper : UnityBootstrapper
    {
        /// &lt;summary>
        /// Make main window class as Prism shell
        /// &lt;/summary>
        protected override DependencyObject CreateShell()
        {
            return ServiceLocator.Current.GetInstance&lt;Shell>();
        }

        /// &lt;summary>
        /// Set the application's window to the current shell and display it
        /// &lt;/summary>
        protected override void InitializeShell()
        {
            Application.Current.MainWindow = (Shell)this.Shell;
            Application.Current.MainWindow.Show();
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Windows</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Microsoft</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Practices</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">ServiceLocation</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Prism</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Unity</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">PrismSample</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">    /// Initializes Prism/Unity components and services</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Bootstrapper</span><span style="color: #D4D4D4"> : </span><span style="color: #4EC9B0">UnityBootstrapper</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #6A9955">        /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">        /// Make main window class as Prism shell</span></span>
<span class="line"><span style="color: #6A9955">        /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">DependencyObject</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">CreateShell</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">ServiceLocator</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Current</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">GetInstance</span><span style="color: #D4D4D4">&lt;</span><span style="color: #4EC9B0">Shell</span><span style="color: #D4D4D4">&gt;();</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">        /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">        /// Set the application&apos;s window to the current shell and display it</span></span>
<span class="line"><span style="color: #6A9955">        /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">InitializeShell</span><span style="color: #D4D4D4">()</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">Application</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Current</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">MainWindow</span><span style="color: #D4D4D4"> = (</span><span style="color: #4EC9B0">Shell</span><span style="color: #D4D4D4">)</span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Shell</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">Application</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Current</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">MainWindow</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Show</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">On a side note, if we were using MEF for our dependency injection container, we&#8217;d add one more override to the Bootstrapper:&nbsp;ConfigureAggregateCatalog(). We&#8217;d then add a new AssemblyCatalog consisting of our Bootstrapper&#8217;s assembly to MEF&#8217;s AggregateCatalog inside that method.</p>



<p class="wp-block-paragraph">All that’s left is to let WPF know that we want the Bootstrapper to be our startup class. First we remove the StartupUri attribute from App.xaml.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">XAML</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;Application x:Class="PrismSample.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    &lt;Application.Resources>         
    &lt;/Application.Resources>
&lt;/Application></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">Application</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">x:Class</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;PrismSample.App&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">             </span><span style="color: #9CDCFE">xmlns:x</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">Application.Resources</span><span style="color: #808080">&gt;</span><span style="color: #D4D4D4">         </span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Application.Resources</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">Application</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">Then in App.xaml.cs we override OnStartup() as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using System.Windows;
namespace PrismSample
{
    /// &lt;summary>
    /// Interaction logic for App.xaml
    /// &lt;/summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            new Bootstrapper().Run();
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Windows</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">PrismSample</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #6A9955">    /// Interaction logic for App.xaml</span></span>
<span class="line"><span style="color: #6A9955">    /// </span><span style="color: #808080">&lt;/</span><span style="color: #569CD6">summary</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">public</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">partial</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">App</span><span style="color: #D4D4D4"> : </span><span style="color: #4EC9B0">Application</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">protected</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">override</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">OnStartup</span><span style="color: #D4D4D4">(</span><span style="color: #4EC9B0">StartupEventArgs</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">e</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">base</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">OnStartup</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">e</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Bootstrapper</span><span style="color: #D4D4D4">().</span><span style="color: #DCDCAA">Run</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">And now our application is ready to run. Granted, it doesn&#8217;t do much at this point, mainly because we haven&#8217;t loaded any modules. We&#8217;ll start adding those in <a href="/latest-thinking/blog/id/9298/a-properly-pleasing-prism-primer--part-3-modules">Part 3: Modules</a>.</p>



<p class="wp-block-paragraph">The solution files and source code for this part can be downloaded by clicking below</p>



<div class="wp-block-file"><a id="wp-block-file--media-7b1784d8-8cd4-4d5f-a1bb-41026f64b8ce" href="https://static.dmcinfo.com/wp-content/uploads/2025/06/PrismSample.zip">PrismSample</a><a href="https://static.dmcinfo.com/wp-content/uploads/2025/06/PrismSample.zip" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-7b1784d8-8cd4-4d5f-a1bb-41026f64b8ce">Download</a></div>



<h2 class="wp-block-heading" id="h-a-properly-pleasing-prism-primer-the-parts">A Properly Pleasing Prism Primer &#8211; The Parts:</h2>



<p class="wp-block-paragraph"><a href="/latest-thinking/blog/id/9282/a-properly-pleasing-prism-primer--part-1-an-introduction">Part 1:&nbsp; An Introduction</a><br>
<a href="/latest-thinking/blog/id/9295/a-properly-pleasing-prism-primer--part-2-the-shell">Part 2:&nbsp; The Shell and Bootstrapper</a><br>
<a href="/latest-thinking/blog/id/9298/a-properly-pleasing-prism-primer--part-3-modules">Part 3:&nbsp; Modules</a></p>



<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/services/application-development/desktop-application-development/c-net/">Learn more about DMC&#8217;s .NET application development services.</a></p>
<p>The post <a href="https://static.dmcinfo.com/blog/25160/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-2-the-shell-and-bootstrapper/">A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 2:  The Shell and Bootstrapper</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 1:  Introduction</title>
		<link>https://static.dmcinfo.com/blog/25239/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-1-introduction/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Fri, 02 Sep 2016 13:01:42 +0000</pubDate>
				<category><![CDATA[PC Application Development]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[MS Visual Studio/.NET]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25239/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-1-introduction/</guid>

					<description><![CDATA[<p>The usage of design patterns is situational. Their purpose is to reduce the overall complexity of an application or to replace unfamiliar complexity with manageable equivalents. For a sufficiently simple application, however, using patterns is often overkill. Even more so if the design pattern itself isn&#8217;t familiar to the developers that will be maintaining the [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25239/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-1-introduction/">A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 1:  Introduction</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">The usage of design patterns is situational. Their purpose is to reduce the overall complexity of an application or to replace unfamiliar complexity with manageable equivalents. For a sufficiently simple application, however, using patterns is often overkill. Even more so if the design pattern itself isn&rsquo;t familiar to the developers that will be maintaining the code. The paradoxical upshot is usage of the pattern can actually increase the complexity if the application is simple.</p>

<p class="wp-block-paragraph">For example, let&rsquo;s say you&rsquo;ve written a GUI that consists of a single button whose purpose when clicked is to produce a bell sound providing conditioned stimulus to make the user drool. (On the internet no one knows you&rsquo;re a dog, after all.) The whole application can and should be handled completely by a single View. Usage of a pattern such as Model-View-Controller, Model-View-Presenter, or Model-View-ViewModel would be a sloppy mess, much like the aforementioned user&rsquo;s screen, keyboard and mouse.</p>

<p class="wp-block-paragraph">But rarely are applications that simple. Most will benefit from at least some pattern use, and as complexity grows, the advantages of patterns greatly exceed the overhead of implementing them. For applications using Windows Presentation Foundation (WPF), Silverlight, Windows 10 UWP, or Xamarin Forms as their user interface framework, this is where Prism can help.</p>

<h2 class="wp-block-heading">What is Prism?</h2>

<p class="wp-block-paragraph">Prism, a project originally developed by Microsoft patterns and practices and now under the stewardship of the <a href="http://www.dotnetfoundation.org/" target="_blank">.NET Foundation</a>, is a collection of resources implementing common design patterns and architectural support for loosely-coupled modular applications. It saves you the time, energy and complexity it would take to implement these resources yourself. To quote Prism&rsquo;s own documentation:</p>

<p class="wp-block-paragraph"><i style="mso-bidi-font-style:normal"><span style="font-size:11.0pt;line-height:107%;font-family:&quot;Calibri&quot;,sans-serif;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&quot;Times New Roman&quot;;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA">Prism provides guidance designed to help you more easily design and build rich, flexible, and easy-to-maintain Windows Presentation Foundation (WPF) desktop applications. Using design patterns such as Model-View-ViewModel (MVVM), Composite View, and Event Aggregator that embody important architectural design principles helps you create a modular application&mdash;using loosely coupled components that can evolve independently. These types of applications are known as composite applications&hellip;.It is expected that the application will evolve significantly over its lifetime in response to new requirements and business opportunities. In short, these applications are &quot;built to last&quot; and &quot;built for change.&quot; Applications that do not demand these characteristics may not benefit from using Prism.</span></i></p>

<p class="wp-block-paragraph">&ldquo;Prism&rdquo; was the early codename for the <em>Composite Application Library (CAL)</em> which was later renamed to <em>Composite Application Guidance for WPF and Silverlight</em>. No doubt realizing that they were headed towards a progression of increasingly long, complex and awkward to verbalize naming conventions, Microsoft took a step back and redubbed it &ldquo;Prism.&rdquo; Prism provides many different functionalities, including modular programming support, event aggregation, shared services, logging, command processing (including built-in implementation of the ICommand interface), deploying to multiple frameworks, support for both Model-View-Presenter (MVP) and Model-View-ViewModel (MVVM) presentation patterns (including built-in implementation of INotifyPropertyChanged) and dependency injection (DI) and inversion of control (IoC). For DI/IoC, Prism includes built-in support for both MEF and Unity, but can be configured to use other DI containers if desired. And since each asset is largely independent from the other assets, an application developer is free to use as many or as few of them as they want, depending on the needs of the application. While this blog series will touch on most of the functionality Prism provides, it will concern itself primarily with combining Prism with WPF, MVVM and Unity for UI framework, presentation model and dependency injection, respectively.</p>

<h2 class="wp-block-heading">Where is Prism?</h2>

<p class="wp-block-paragraph">The Prism libraries and their source code are available on <a href="https://github.com/PrismLibrary/Prism" target="_blank">GitHub</a>. The libraries are also available through NuGet. As of this blog post, the current version is 6.2.0.</p>

<p class="wp-block-paragraph">Documentation can be found also at GitHub or through <a href="https://msdn.microsoft.com/en-us/library/ff921153(v=pandp.40).aspx" target="_blank">MSDN</a>. The documentation is well written, thorough and organized and also includes some sample projects. However, it&rsquo;s also fairly long and detailed, so this blog series will try to provide you with enough of an overview to get you started working with Prism without having to read the entire documentation start to finish. As a result, there are a considerable number of documented features that I won&apos;t be addressing in this series.</p>

<h2 class="wp-block-heading">How Do I Use Prism?</h2>

<p class="wp-block-paragraph">In all honesty, considering all the functionality Prism provides, a full answer to that question exceeds what one can be reasonably expected to accomplish in a blog series. However, if you want a good foundation from which you can start programming with Prism and/or better absorb the documentation already out there, this series has that in spades. It will walk you through a step-by-step creation of a fairly simple WPF application that uses MVVM and Unity and touches upon a significant portion of the more commonly used functionality Prism provides. Each part of the blog will build on the previous part, and source code will be available, along with solution and project files. (Visual Studio 2015; .NET Framework SDK 4.6.2)</p>

<p class="wp-block-paragraph">Note that this series assumes the reader has at least a passing familiarity with C#, WPF, and the MVVM design pattern.</p>

<p class="wp-block-paragraph">So without further ado, we continue on to&nbsp; <a href="https://static.dmcinfo.com/latest-thinking/blog/id/9295/a-properly-pleasing-prism-primer--part-2-the-shell">Part 2:&nbsp; The Shell and Bootstrapper</a></p>

<h2 class="wp-block-heading">A Properly Pleasing Prism Primer &#8211; The Parts:</h2>

<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/latest-thinking/blog/id/9282/a-properly-pleasing-prism-primer--part-1-an-introduction">Part 1:&nbsp; An Introduction</a><br />
<a href="https://static.dmcinfo.com/latest-thinking/blog/id/9295/a-properly-pleasing-prism-primer--part-2-the-shell">Part 2:&nbsp; The Shell and Bootstrapper</a><br />
<a href="https://static.dmcinfo.com/latest-thinking/blog/id/9298/a-properly-pleasing-prism-primer--part-3-modules">Part 3:&nbsp; Modules</a></p>

<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/latest-thinking/blog/articletype/categoryview/categoryid/136/c-net-application-development">Learn more about DMC&apos;s .NET application development services.</a></p>
<p>The post <a href="https://static.dmcinfo.com/blog/25239/a-properly-pleasing-primer-tutorial-for-wpf-prism-part-1-introduction/">A Properly Pleasing Primer Tutorial for WPF Prism &#8211; Part 1:  Introduction</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Use FANUC PC Developer&#8217;s Kit (PCDK)</title>
		<link>https://static.dmcinfo.com/blog/25767/how-to-use-fanuc-pc-developers-kit-pcdk/</link>
		
		<dc:creator><![CDATA[Frank May]]></dc:creator>
		<pubDate>Tue, 26 Apr 2016 12:38:00 +0000</pubDate>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Manufacturing Automation & Intelligence]]></category>
		<category><![CDATA[Motion Control]]></category>
		<category><![CDATA[PC Application Development]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Software Development]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25767/how-to-use-fanuc-pc-developers-kit-pcdk/</guid>

					<description><![CDATA[<p>FANUC offers an easy way to command and configure a robot from a PC using their PC Developer&#8217;s Kit (PCDK).The kit allows a PC to access variables, registers, IO, programs, positions, and alarms on the robot. Most of the help documentation already covers Visual Basic, so I&#8217;ll explain how to get started with C#. Installation [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25767/how-to-use-fanuc-pc-developers-kit-pcdk/">How to Use FANUC PC Developer&#8217;s Kit (PCDK)</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">FANUC offers an easy way to command and configure a robot from a PC using their PC Developer&#8217;s Kit (<a href="https://www.fanucamerica.com/products/robots/software" target="_blank" rel="noreferrer noopener">PCDK</a>).The kit allows a PC to access variables, registers, IO, programs, positions, and alarms on the robot. Most of the help documentation already covers Visual Basic, so I&#8217;ll explain how to get started with C#.</p>



<h2 class="wp-block-heading" id="h-installation"><strong>Installation</strong></h2>



<p class="wp-block-paragraph">First step is to install Visual Studio.&nbsp;<a href="https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx" target="_blank">Visual Studio Community</a>&nbsp;is free and works perfectly for this application.</p>



<p class="wp-block-paragraph">After installing Visual Studio, go through the PCDK installer.&nbsp;</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/FanucPCDK.png" alt=""/></figure>



<h2 class="wp-block-heading" id="h-getting-started-with-fanuc-pcdk"><strong>Getting Started with FANUC PCDK</strong></h2>



<p class="wp-block-paragraph">Next, start up Visual Studio and create a new Console Application. I called mine &#8220;FanucTest&#8221;.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/FanucConsoleApplication.png" alt="FANUC Console application "/></figure>



<p class="wp-block-paragraph">After clicking OK, right click on the &#8220;References&#8221; in the solution, and click &#8220;Add Reference&#8221;.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/FanucReferences.png" alt="FANUC project references "/></figure>



<p class="wp-block-paragraph">Under COM, find FANUC Robotics Controller Interface. Select it and click OK.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/FanucCOM.png" alt="FANUC COM Reference"/></figure>



<p class="wp-block-paragraph">Now to begin writing code!</p>



<h2 class="wp-block-heading" id="h-connecting-to-a-robot"><strong>Connecting to a Robot</strong></h2>



<p class="wp-block-paragraph">Add the following highlighted lines to your code to connect to your robot. If this runs, you&#8217;ve <b>successfully</b> installed PCDK and you&#8217;re ready to communicate with your robot.&nbsp;</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FRRobot;      //uses the robot reference we just added

namespace FanucTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();

            //Create a robot object
            FRCRobot mobjRobot = new FRCRobot();
            //Connect to your robot
            mobjRobot.Connect("192.168.1.123");
            bool connected = mobjRobot.IsConnected;

        }

    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Collections</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Generic</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Linq</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Text</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">System</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Threading</span><span style="color: #D4D4D4">.</span><span style="color: #4EC9B0">Tasks</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #C586C0">using</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">FRRobot</span><span style="color: #D4D4D4">;      </span><span style="color: #6A9955">//uses the robot reference we just added</span></span>
<span class="line"></span>
<span class="line"><span style="color: #569CD6">namespace</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">FanucTest</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">class</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">Program</span></span>
<span class="line"><span style="color: #D4D4D4">    {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #569CD6">static</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">void</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">Main</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">string</span><span style="color: #D4D4D4">[] </span><span style="color: #9CDCFE">args</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">        {</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">Console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">WriteLine</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Press any key to continue...&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">Console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">ReadKey</span><span style="color: #D4D4D4">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">            //Create a robot object</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #4EC9B0">FRCRobot</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">mobjRobot</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #4EC9B0">FRCRobot</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #6A9955">            //Connect to your robot</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">mobjRobot</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Connect</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;192.168.1.123&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #569CD6">bool</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">connected</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">mobjRobot</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">IsConnected</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="wp-block-heading" id="h-updating-a-position-register">Updating a Position Register</h2>



<p class="wp-block-paragraph">To finish off this hello world program, add the following lines of code to update a position register. We&#8217;re accessing position register 1 below and updating the values.&nbsp;</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">C#</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>  //See help topics "Efficient Access to Positions"
            FRCSysPositions sysPositions = mobjRobot.RegPositions;
            FRCSysPosition sysPosition = sysPositions&#91;1&#93;;
            FRCSysGroupPosition sysGroupPosition = sysPosition.Group&#91;1&#93;;
            FRCXyzWpr xyzWpr = sysGroupPosition.Formats&#91;FRETypeCodeConstants.frXyzWpr&#93;;
            //Prepare updated X,Y,Z,W,P, and R values of position register 1
            xyzWpr.X = 475;
            xyzWpr.Y = -275;
            xyzWpr.Z = -231;
            xyzWpr.W = -176;
            xyzWpr.P = 0;
            xyzWpr.R = 0;
            try
            {
                //Update position register 1
                sysGroupPosition.Update();

            }</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">  //See help topics &quot;Efficient Access to Positions&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #4EC9B0">FRCSysPositions</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">sysPositions</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">mobjRobot</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">RegPositions</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #4EC9B0">FRCSysPosition</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">sysPosition</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">sysPositions</span><span style="color: #D4D4D4">&#91;</span><span style="color: #B5CEA8">1</span><span style="color: #D4D4D4">&#93;;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #4EC9B0">FRCSysGroupPosition</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">sysGroupPosition</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">sysPosition</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Group</span><span style="color: #D4D4D4">&#91;</span><span style="color: #B5CEA8">1</span><span style="color: #D4D4D4">&#93;;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #4EC9B0">FRCXyzWpr</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">sysGroupPosition</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Formats</span><span style="color: #D4D4D4">&#91;</span><span style="color: #9CDCFE">FRETypeCodeConstants</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">frXyzWpr</span><span style="color: #D4D4D4">&#93;;</span></span>
<span class="line"><span style="color: #6A9955">            //Prepare updated X,Y,Z,W,P, and R values of position register 1</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">X</span><span style="color: #D4D4D4"> = </span><span style="color: #B5CEA8">475</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Y</span><span style="color: #D4D4D4"> = -</span><span style="color: #B5CEA8">275</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">Z</span><span style="color: #D4D4D4"> = -</span><span style="color: #B5CEA8">231</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">W</span><span style="color: #D4D4D4"> = -</span><span style="color: #B5CEA8">176</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">P</span><span style="color: #D4D4D4"> = </span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #9CDCFE">xyzWpr</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">R</span><span style="color: #D4D4D4"> = </span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">            </span><span style="color: #C586C0">try</span></span>
<span class="line"><span style="color: #D4D4D4">            {</span></span>
<span class="line"><span style="color: #6A9955">                //Update position register 1</span></span>
<span class="line"><span style="color: #D4D4D4">                </span><span style="color: #9CDCFE">sysGroupPosition</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">Update</span><span style="color: #D4D4D4">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">            }</span></span></code></pre></div>



<p class="wp-block-paragraph">To learn how to do more with the robot, check out the PCDK help documentation. Depending on your version of Windows, you might need to install another program to view the help documentation.&nbsp;</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/PCDKHelp.png" alt=""/></figure>



<p class="wp-block-paragraph"><a href="/services/manufacturing-automation-and-intelligence">Learn more about DMC&#8217;s Manufacturing and Automation Intelligence services</a>&nbsp;and <a href="https://static.dmcinfo.com/contact">contact us</a> today!</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25767/how-to-use-fanuc-pc-developers-kit-pcdk/">How to Use FANUC PC Developer&#8217;s Kit (PCDK)</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Connecting Custom Applications to the Factory Floor</title>
		<link>https://static.dmcinfo.com/blog/26086/connecting-custom-applications-to-the-factory-floor/</link>
		
		<dc:creator><![CDATA[Jon Carson]]></dc:creator>
		<pubDate>Fri, 18 Dec 2015 10:31:29 +0000</pubDate>
				<category><![CDATA[PC Application Development]]></category>
		<category><![CDATA[PLC]]></category>
		<category><![CDATA[Siemens PLC]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[Custom Applications]]></category>
		<category><![CDATA[MS Visual Studio/.NET]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/26086/connecting-custom-applications-to-the-factory-floor/</guid>

					<description><![CDATA[<p>DMC has expertise in both industrial and PC-based software development. In other words, we do a great deal of projects involving PLCs; but we also write plenty of complex PC-based apps. But my personal favorites are projects that combine the two. We’re seeing them more and more. Don’t get me wrong, off the shelf solutions [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/26086/connecting-custom-applications-to-the-factory-floor/">Connecting Custom Applications to the Factory Floor</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">DMC has expertise in both industrial and PC-based software development. In other words, we do a great deal of projects involving PLCs; but we also write plenty of complex PC-based apps. But my personal favorites are projects that combine the two.</p>



<p class="wp-block-paragraph">We’re seeing them more and more. Don’t get me wrong, off the shelf solutions are great, and should be used wherever they make sense. But sometimes they don’t fit all of the requirements our customers need. Here are some examples I’ve encountered over the past few months where a custom PC app made the most sense in an industrial setting:</p>



<p class="wp-block-paragraph">1.&nbsp;&nbsp; &nbsp;A program that automatically parses CAD drawings of a part, and then sends the resulting data to a PLC.<br>
2.&nbsp;&nbsp; &nbsp;Multiple offsite PLCs sending Ethernet packets over a cellular modem, to a server-side application that received, parsed, and logged the data.<br>
3.&nbsp;&nbsp; &nbsp;A web-based interface that translate data back and forth between a custom SQL server and multiple PLCs.</p>



<p class="wp-block-paragraph">So we’ve established there are situations where a custom app makes sense. But how does one write this type of program? What tools are out there to connect the dots? As it turns out, there are plenty! Here are some of my favorites:</p>



<p class="wp-block-paragraph"><strong><a href="https://github.com/dotnetprojects/DotNetSiemensPLCToolBoxLibrary" target="_blank">Dot Net PLC Toolbox&nbsp;</a></strong><br>
Believe it or not, there’s actually a pretty strong community of .NET developers interested in interfacing to PLCs. One of my favorite open-source libraries is the Dot Net PLC Toolbox. This in-depth, free library allows .NET apps to parse PLC projects, as well as communicate, read tags, and go online. Last year I personally was involved with using this toolbox to create an open-source <a href="https://github.com/boriz/s7-diff-merge" target="_blank">S7 Source Control Utility</a>.</p>



<p class="wp-block-paragraph"><strong>InGear Drivers </strong><br>The guys over at InGear have created easy-to-use .NET drivers for Siemens, OPC, and more. Sure, there are free tools available, but sometimes it’s nice to pay for a product just so you have a support team to rely on when you need them.</p>



<p class="wp-block-paragraph"><a href="http://jamod.sourceforge.net/" target="_blank"><strong>Jamod</strong></a><br>
Most of our development is built on .NET, but sometimes client requirements dictate another language like Java. This is where a library like Jamod can be handy. Jamod is a Java library written for Modbus (serial, TCP, or UDP). Since Modbus is such an open protocol, this library makes it easy to connect your Java application to PLCs, drives, smart IO, and more.</p>



<p class="wp-block-paragraph"><a href="https://support.industry.siemens.com/cs/document/108716692/tia-portal-openness%3A-introduction-and-demo-application?dti=0&amp;lc=en-WW" target="_blank"><strong>TIA Portal Openness</strong></a>&nbsp;<br>
For Siemens PLCs in particular, there are official tools available to the interested programmer. With the latest version of TIA Portal, Siemens released an API used to interface with PLC programs. This code library allows developers to “automate” their code development by exporting, modifying, and importing TIA projects. I was pretty familiar with their old software, the <a href="/latest-thinking/blog/id/8446/automating-siemens-s7-and-simotion-tasks-using-c-net">Command Interface</a>, and was excited to see them release a tool for Portal as well.</p>



<p class="wp-block-paragraph">Learn more about DMC&#8217;s <a href="/services/embedded-development-and-embedded-programming"><strong>.NET and automation intelligence capabilities</strong></a>.&nbsp;</p>
<p>The post <a href="https://static.dmcinfo.com/blog/26086/connecting-custom-applications-to-the-factory-floor/">Connecting Custom Applications to the Factory Floor</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Lunch for Business: A Better Way to Lunch</title>
		<link>https://static.dmcinfo.com/blog/26095/lunch-for-business-a-better-way-to-lunch/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Thu, 10 Dec 2015 12:56:05 +0000</pubDate>
				<category><![CDATA[Culture]]></category>
		<category><![CDATA[User Interface Design]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C# .NET Application Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/26095/lunch-for-business-a-better-way-to-lunch/</guid>

					<description><![CDATA[<p>DMC had a lunch problem. When noon rolled around, someone would inevitably decide they wanted to go to Chipotle. They&#8217;d get up from their desk and circle around the office, asking everyone they saw if they wanted to jump on the Chipotle train. But &#8220;everyone&#8221; wasn&#8217;t actually everyone, since everyone isn&#8217;t necessarily at their desk [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/26095/lunch-for-business-a-better-way-to-lunch/">Lunch for Business: A Better Way to Lunch</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">DMC had a lunch problem. When noon rolled around, someone would inevitably decide they wanted to go to Chipotle. They&rsquo;d get up from their desk and circle around the office, asking everyone they saw if they wanted to jump on the Chipotle train. But &ldquo;everyone&rdquo; wasn&rsquo;t actually everyone, since everyone isn&rsquo;t necessarily at their desk at 11:58 AM. Some people would be on the phone, others in collaboration rooms. Perhaps they&rsquo;d even be on the other side of the office, asking if anyone wanted to go to Taco Bell! And so your group would get back to DMC, burritos in hand, only to find some very sad people who missed out because they didn&rsquo;t know where you were going.</p>

<p class="wp-block-paragraph">Sam, Sudeep, and I were fed up with this. On our latest&nbsp;<a href="https://static.dmcinfo.com/latest-thinking/blog/id/9042/fedex-day-2015">FedEx Day</a>, which is a day dedicated to fun, internal improvement projects, we decided there had to a better way. An advanced, easy-to-use team communication and collaboration tool that served a single, highly-specialized purpose: to figure out what we wanted to eat.</p>

<p class="wp-block-paragraph">And since we&rsquo;re a creative bunch, we made exactly that and named it Lunch for Business.</p>

<figure class="wp-block-image"><img decoding="async" alt="Lunch for Business Interface" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/l4b.png"  /></figure>

<p class="wp-block-paragraph"><strong>Application Features</strong></p>

<p class="wp-block-paragraph"><span style="line-height: 1.6;">It can be hard to get a large group of people all using the same new tool. That&rsquo;s why our number one goal was to make this stupid simple. It installs with a single click, automatically launches on startup, and lives stowed away in your system tray. &nbsp;</span></p>

<p class="wp-block-paragraph">When you decide that yes, you would very much like a burrito today, you can double click the tray icon, type in &ldquo;Chipotle&rdquo;, and hit suggest. At that moment, everyone currently running Lunch for Business gets a little balloon notification saying that a suggestion has been made. People can then click &ldquo;Join&rdquo; to hop on your bandwagon, or they can make a suggestion of their own.</p>

<p class="wp-block-paragraph">Once you&rsquo;ve joined a lunch spot, you can let people know you&rsquo;re willing to drive others there. You can also click on the lunch spot to launch Google Maps for directions and check out the traffic conditions. When you&rsquo;re ready to go, you can click &ldquo;Leave&rdquo; and everyone in your group will get notified that it&rsquo;s time to head out.</p>

<p class="wp-block-paragraph">Lunch for Business was adopted quickly and has become the de facto way of suggesting places to go eat in the Chicago office. The days of walking around in circles are long gone.&nbsp;<span style="line-height: 1.6;">Aside from fulfilling an extremely important need, the project has been a nice way to check out cool technologies like </span><a href="http://www.asp.net/signalr" style="line-height: 1.6;" target="_blank">SignalR</a><span style="line-height: 1.6;">, </span><a href="http://hangfire.io/" style="line-height: 1.6;" target="_blank">Hangfire</a><span style="line-height: 1.6;">, and the </span><a href="https://developers.google.com/maps/?hl=en" style="line-height: 1.6;" target="_blank">Google Maps API</a><span style="line-height: 1.6;">.</span></p>

<p class="wp-block-paragraph">We also used a variety of familiar favorites to build the application, including:</p>

<ul class="wp-block-list">
 <li>C#</li>
 <li>.NET</li>
 <li>WebSockets</li>
 <li><a href="/services/application-development/web-application-development/aspnet-and-aspnet-mvc">ASP.NET MVC</a></li>
 <li>WPF</li>
 <li>Microsoft SQL Server</li>
</ul>

<p class="wp-block-paragraph"><strong>A Closer Look at DMC&apos;s Noshing Preferences</strong></p>

<p class="wp-block-paragraph">As an added bonus, keeping track of lunch spots has let us keep statistics on where DMC likes to eat. Chipotle and Mariano&rsquo;s dominate the list, with one of the two being suggested half of the time. But, thankfully, the other half includes a much more diverse list of places in our neighborhood. DMC clearly has some favorites, but we still like to explore different options.</p>

<figure class="wp-block-image"><img decoding="async" alt="Lunch For Business Suggestion Stats" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/wheredmceats.png"  /></figure>

<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/services/embedded-development-and-embedded-programming">Learn more about DMC&apos;s Custom Software and Hardware Development services.</a></p>
<p>The post <a href="https://static.dmcinfo.com/blog/26095/lunch-for-business-a-better-way-to-lunch/">Lunch for Business: A Better Way to Lunch</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
