<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>CodeProject Latest postings for WPF</title>
    <link>https://www.codeproject.com</link>
    <description>Latest postings for WPF from CodeProject</description>
    <language>en-us</language>
    <image>
      <title>CodeProject Latest postings for WPF</title>
      <url>https://www.codeproject.com/App_Themes/Std/Img/logo100x30.gif</url>
      <link>https://www.codeproject.com</link>
      <width>100</width>
      <height>30</height>
      <description>CodeProject</description>
    </image>
    <copyright>Copyright  CodeProject, 1999-2024</copyright>
    <webMaster>Webmaster@codeproject.com (Webmaster)</webMaster>
    <lastBuildDate>Mon, 01 Jul 2024 11:03:00 GMT</lastBuildDate>
    <ttl>20</ttl>
    <generator>C# Hand-coded goodness</generator>
    <item>
      <title>HOW TO ANSWER A QUESTION</title>
      <description>Apologies for the shouting but this is important.&lt;br /&gt;
&lt;br /&gt;
When answering a question please:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Read the question carefully&lt;/li&gt;&lt;li&gt;Understand that English isn't everyone's first language so be lenient of bad spelling and grammar&lt;/li&gt;&lt;li&gt;If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. &lt;b&gt;Insults are not welcome&lt;/b&gt;&lt;/li&gt;&lt;li&gt;If the question is inappropriate then click the 'vote to remove message' button&lt;/li&gt;&lt;/ol&gt;Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid. &lt;br /&gt;
&lt;br /&gt;
&lt;div class="ForumSig"&gt;cheers,&lt;br /&gt;
Chris Maunder&lt;br /&gt;
&lt;br /&gt;
The Code Project Co-founder&lt;br /&gt;
Microsoft C++ MVP&lt;/div&gt;</description>
      <author>Chris Maunder</author>
      <link>https://www.codeproject.com/Messages/3122382/HOW-TO-ANSWER-A-QUESTION</link>
      <pubDate>Thu, 16 Jul 2009 13:09:00 GMT</pubDate>
      <guid>3_3122382</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>How to get an answer to your question</title>
      <description>For those new to message boards please try to follow a few simple rules when posting your question.&lt;ol&gt;&lt;li&gt;&lt;b&gt;Choose the correct forum for your message&lt;/b&gt;. Posting a VB.NET question in the C++ forum will end in tears.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;&lt;b&gt;Be specific!&lt;/b&gt; Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Keep the subject line brief, but descriptive. eg "File Serialization problem"&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;&lt;b&gt;Do not remove or empty a message&lt;/b&gt; if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;If you are posting source code with your question, place it inside &amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt; tags. We advise you also check the "Encode "&amp;lt;" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums. &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;No advertising or soliciting.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;
&lt;div class="signature"&gt;cheers,&lt;br /&gt;
Chris Maunder&lt;br /&gt;
&lt;br /&gt;
The Code Project Co-founder&lt;br /&gt;
&lt;div class="SmallText"&gt;Microsoft C++ MVP&lt;/div&gt;&lt;/div&gt;</description>
      <author>Chris Maunder</author>
      <link>https://www.codeproject.com/Messages/3122369/How-to-get-an-answer-to-your-question</link>
      <pubDate>Thu, 16 Jul 2009 13:05:00 GMT</pubDate>
      <guid>3_3122369</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>How to create and save High Score in my Tetris game in wpf c#?</title>
      <description>I wanna know isn't save in my computer .If i run my game and score high score and then close my game.When i run it again next time there will remain my high score every time i run.&lt;br /&gt;
&lt;br /&gt;
Plz tell me and thank you.</description>
      <author>Member 16286091</author>
      <link>https://www.codeproject.com/Messages/6008084/How-to-create-and-save-High-Score-in-my-Tetris-gam</link>
      <pubDate>Mon, 01 Jul 2024 11:03:00 GMT</pubDate>
      <guid>3_6008084</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>select text box lines and remove</title>
      <description>I have a textbox display that has incoming data from a serial port that I display.  After 200 lines of data that has came in I want to remove 20 lines at the beginning.  Here is my code:&lt;br /&gt;
&lt;div class='pre-lang' id='premain374023'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode374023' class='copy-code' data-index='374023' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre374023' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; TextBoxADCPDisplay_TextChanged(&lt;span class="code-keyword"&gt;object&lt;/span&gt; sender, TextChangedEventArgs e)
{

    TextBoxADCPDisplay.SelectionStart = TextBoxADCPDisplay.Text.Length;
    TextBoxADCPDisplay.ScrollToEnd();
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (TextBoxADCPDisplay.LineCount &amp;gt; &lt;span class="code-digit"&gt;200&lt;/span&gt;)
    {
        TextBoxADCPDisplay.Select(&lt;span class="code-digit"&gt;0&lt;/span&gt;, &lt;span class="code-digit"&gt;20&lt;/span&gt;);
        TextBoxADCPDisplay.SelectedText = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;;
        
    }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I get some strange behavior.  Where after I hit 200 lines I see multiple lines that are the same where they should be different, but if I manually scroll up a little and scroll back down the lines of data that are coming in display as they should.  What am I doing wrong?</description>
      <author>geomeo123</author>
      <link>https://www.codeproject.com/Messages/6006851/select-text-box-lines-and-remove</link>
      <pubDate>Sun, 23 Jun 2024 02:30:00 GMT</pubDate>
      <guid>3_6006851</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>Custom Control Based On Combobox - Replace Part Of The Combobox</title>
      <description>I'm looking at the &lt;a href="https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/combobox-styles-and-templates?view=netframeworkdesktop-4.8"&gt;deault combobox style&lt;/a&gt;[&lt;a href="https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/combobox-styles-and-templates?view=netframeworkdesktop-4.8" target="_blank"&gt;^&lt;/a&gt;]&lt;br /&gt;
&lt;br /&gt;
I'm not entirely sure how to ask what I'm thinking, so please bear with me...&lt;br /&gt;
&lt;br /&gt;
Is it possible to replace a part of the control? For example, if I wanted to create a custome combobox. I know in the C# file I just subclass it
&lt;div class='pre-lang' id='premain170951'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode170951' class='copy-code' data-index='170951' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre170951' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; MyComboBox : ComboBox
{
    &lt;span class="code-keyword"&gt;static&lt;/span&gt; MyComboBox()
    {
        DefaultStyleKeyProperty.OverrideMetadata(&lt;span class="code-keyword"&gt;typeof&lt;/span&gt;(MyComboBox),
            &lt;span class="code-keyword"&gt;new&lt;/span&gt; FrameworkPropertyMetadata(&lt;span class="code-keyword"&gt;typeof&lt;/span&gt;(MyComboBox)));
    }

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Add some DP&amp;#39;s and logic&lt;/span&gt;
}&lt;/pre&gt;
&lt;br /&gt;
But in the Generic.xaml, I seems like I would need to have ALL the default xaml from the site above - so that it looks &amp;amp; functions like a combobox.&lt;br /&gt;
&lt;br /&gt;
Is there a way for me to provide just a new ContentSite? Can I justy define that in my Generic.xaml and somehow apply that to my combobox?&lt;br /&gt;
&lt;br /&gt;
Ot do I need to copy in all the default XAML?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/6005750/Custom-Control-Based-On-Combobox-Replace-Part-Of-T</link>
      <pubDate>Sat, 15 Jun 2024 04:27:00 GMT</pubDate>
      <guid>3_6005750</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>Invoke WPF</title>
      <description>I have some code I'm trying to move to my view model.  And it appears that my Invoke method does not work in it.  I have the following code...&lt;br /&gt;
&lt;div class='pre-lang' id='premain858084'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode858084' class='copy-code' data-index='858084' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre858084' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;delegate&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; SetTextCallBackSMT(&lt;span class="code-keyword"&gt;string&lt;/span&gt; text);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Handing my serial port&lt;br /&gt;
&lt;div class='pre-lang' id='premain499135'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode499135' class='copy-code' data-index='499135' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre499135' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;string&lt;/span&gt; SMTData = SpSMT.ReadExisting();
&lt;span class="code-keyword"&gt;if&lt;/span&gt; (SMTData.Contains(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;\r"&lt;/span&gt;))
{
    modeSMT = ModeSMT.readLineSMTData;
}
&lt;span class="code-keyword"&gt;else&lt;/span&gt;
{

    Invoke(&lt;span class="code-keyword"&gt;new&lt;/span&gt; SetTextCallBackSMT(SetTextSMTDisplay), SMTData.ToString());

}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
And my set text method....&lt;br /&gt;
&lt;div class='pre-lang' id='premain137148'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode137148' class='copy-code' data-index='137148' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre137148' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; SetTextSMTDisplay(&lt;span class="code-keyword"&gt;string&lt;/span&gt; text)
{
    &lt;span class="code-keyword"&gt;this&lt;/span&gt;.RichTextBoxSMTDisplay.Text += text;
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The problem I'm having is that Invoke does not exist in the current context.  I've tried adding forms name space.  I've tried Dispatcher.Invoke, but I can't get that to work either. Any ideas?</description>
      <author>geomeo123</author>
      <link>https://www.codeproject.com/Messages/6003688/Invoke-WPF</link>
      <pubDate>Sun, 02 Jun 2024 01:31:00 GMT</pubDate>
      <guid>3_6003688</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>ICommand Wpf form load properties?</title>
      <description>I'm trying to update my program to WPF MVVM with Icommands to make my program look a little better and reduce the amount of event handlers, clutter etc, which I've managed to make workish.  Well if I press a button in WPF my message box executes, so that's always good right? But I have some properties in my old windows form load event that I need to move over and I'm not exactly sure how I would implement that.  I'm using the serialport io namespace and so I'm loading things like this at form load time:&lt;br /&gt;
&lt;div class='pre-lang' id='premain386485'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode386485' class='copy-code' data-index='386485' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre386485' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
SP.Handshake = Handshake.None;
SP.DataReceived += &lt;span class="code-keyword"&gt;new&lt;/span&gt; SerialDataReceivedEventHandler(SP_DataReceived);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
SP meaning serial port.  Do I put the above in my wpf form load event and make these  public so that my modelview class can see them?  Or is there an alternative?  My model view class inherits from my viewbasemodel so it doesn't allow inheriting from another base class. I could move them to my viewbasemodel class, but I'm not sure about that one either. I still have to make them run at form load. I have to say I'm only half understanding the modelview at the moment.  The tutorials online aren't clicking just yet. But I have made it workish so that's always good.</description>
      <author>geomeo123</author>
      <link>https://www.codeproject.com/Messages/6003442/ICommand-Wpf-form-load-properties</link>
      <pubDate>Fri, 31 May 2024 00:11:00 GMT</pubDate>
      <guid>3_6003442</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>WrapPanel / ItemsControl Problem</title>
      <description>I'm trying to use a WrapPanel inside an ItemsControl. I'm &lt;a href="https://wpf.2000things.com/2014/02/25/1016-displaying-a-collection-of-items-in-a-wrappanel/"&gt;following this&lt;/a&gt;[&lt;a href="https://wpf.2000things.com/2014/02/25/1016-displaying-a-collection-of-items-in-a-wrappanel/" target="_blank"&gt;^&lt;/a&gt;].&lt;br /&gt;
&lt;br /&gt;
The difference is that mine is bound to a  list of objects called Backups.&lt;br /&gt;
&lt;br /&gt;
Here's what I have. When I run it, I don't see any of the data.
&lt;div class='pre-lang' id='premain84196'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode84196' class='copy-code' data-index='84196' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre84196' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;Border Grid.Row=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1"&lt;/span&gt;
        CornerRadius=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;20"&lt;/span&gt;
        Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;35"&lt;/span&gt;
        Padding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;10"&lt;/span&gt;
        Background=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Tan"&lt;/span&gt;
        BorderThickness=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;3"&lt;/span&gt;
        BorderBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;SteelBlue"&lt;/span&gt;&amp;gt;

    &amp;lt;ScrollViewer VerticalScrollBarVisibility=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Auto"&lt;/span&gt;
                    Background=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Teal"&lt;/span&gt;
                    Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;10"&lt;/span&gt;&amp;gt;

        &amp;lt;ItemsControl ItemsSource=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Backups}"&lt;/span&gt;&amp;gt;

            &amp;lt;ItemsControl.ItemTemplate&amp;gt;

                &amp;lt;DataTemplate&amp;gt;

                    &amp;lt;Border Background=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Salmon"&lt;/span&gt;
                            BorderBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Blue"&lt;/span&gt;
                            BorderThickness=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;3"&lt;/span&gt;&amp;gt;

                        &amp;lt;StackPanel Orientation=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Vertical"&lt;/span&gt;&amp;gt;

                            &amp;lt;Rectangle Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;5"&lt;/span&gt; 
                                        Width=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;100"&lt;/span&gt; 
                                        Height=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;100"&lt;/span&gt; 
                                        Fill=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Yellow"&lt;/span&gt;
                                        HorizontalAlignment=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Center"&lt;/span&gt;/&amp;gt;
                            &amp;lt;TextBlock Text=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;THIS IS A TEST"&lt;/span&gt;
                                        HorizontalAlignment=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Center"&lt;/span&gt;
                                        Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;5"&lt;/span&gt;/&amp;gt;

                        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

                    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Border&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

                &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

            &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

            &amp;lt;ItemsControl.ItemsPanel&amp;gt;
                &amp;lt;ItemsPanelTemplate&amp;gt;
                    &amp;lt;WrapPanel IsItemsHost=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;True"&lt;/span&gt;/&amp;gt;
                &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsPanelTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsControl.ItemsPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsControl&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ScrollViewer&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Border&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/6003275/WrapPanel-ItemsControl-Problem</link>
      <pubDate>Thu, 30 May 2024 02:15:00 GMT</pubDate>
      <guid>3_6003275</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>Initialize Webview2 in WPF Application work for windows user authentication</title>
      <description>I am facing an exception while WebView initialize. It is working perfectly fine when i debug my code on VS 2019 but when i make an installer and install it on VM Windows 10 Machine it gives me an exception which i can get with help of Logs.&lt;br /&gt;
I have added UDF as well in my client machine and install Microsoft edge runtime(124.0.2478.97)&lt;br /&gt;
&lt;br /&gt;
Please Suggest any one what i need to add to resolve this issue.&lt;br /&gt;
&lt;br /&gt;
Code Block 
&lt;div class='pre-lang' id='premain55240'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode55240' class='copy-code' data-index='55240' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre55240' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
MainWindow.xaml.cs
&lt;span class="code-keyword"&gt;using&lt;/span&gt; Microsoft.Web.WebView2.Core;
&lt;span class="code-keyword"&gt;using&lt;/span&gt; Microsoft.Web.WebView2.Wpf; 
&lt;span class="code-keyword"&gt;public&lt;/span&gt; MainWindow()
        {
           InitializeComponent();
           InitializeAndNavigateAsync( url);
        }
  &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;async&lt;/span&gt; Task InitializeAndNavigateAsync(&lt;span class="code-keyword"&gt;string&lt;/span&gt; url)
        {
            &lt;span class="code-keyword"&gt;await&lt;/span&gt; InitializeWebViewAsync();
            &lt;span class="code-keyword"&gt;await&lt;/span&gt; NavigateToUrlAsync(url);
        }

        &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;async&lt;/span&gt; Task InitializeWebViewAsync()
        {
            &lt;span class="code-keyword"&gt;try&lt;/span&gt;
            {
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 initialize start"&lt;/span&gt;);
                &lt;span class="code-keyword"&gt;await&lt;/span&gt; webView.EnsureCoreWebView2Async(&lt;span class="code-keyword"&gt;null&lt;/span&gt;);
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 initialize stop"&lt;/span&gt;);
            }
            &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (Exception e)
            {
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 initialization failed.{e.Message}"&lt;/span&gt;);
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 initialization failed.{e.StackTrace}"&lt;/span&gt;);
            }

        }

        &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;async&lt;/span&gt; Task NavigateToUrlAsync(&lt;span class="code-keyword"&gt;string&lt;/span&gt; url)
        {
            &lt;span class="code-keyword"&gt;try&lt;/span&gt;
            {
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 NavigateToUrlAsync start"&lt;/span&gt;);
                webView.CoreWebView2.Navigate(url);
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 NavigateToUrlAsync stop"&lt;/span&gt;);
            }
            &lt;span class="code-keyword"&gt;catch&lt;/span&gt; (Exception e)
            {
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 NavigateToUrlAsync failed.{e.Message}"&lt;/span&gt;);
                log.Debug($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;WebView2 NavigateToUrlAsync failed.{e.StackTrace}"&lt;/span&gt;);

            }

        }&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Exception is :&lt;/b&gt; 
&lt;div class='pre-lang' id='premain805572'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode805572' class='copy-code' data-index='805572' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre805572' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
WebView2 initialization failed.Server execution failed (Exception &lt;span class="code-sdkkeyword"&gt;from&lt;/span&gt; HRESULT: &lt;span class="code-digit"&gt;0x80080005&lt;/span&gt; (CO_E_SERVER_EXEC_FAILURE))
2024-05-14 &lt;span class="code-digit"&gt;06&lt;/span&gt;:&lt;span class="code-digit"&gt;34&lt;/span&gt;:&lt;span class="code-digit"&gt;45&lt;/span&gt;.4923|DEBUG|debug|WebView2 initialization failed.   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(&lt;span class="code-sdkkeyword"&gt;Int32&lt;/span&gt; errorCode, &lt;span class="code-sdkkeyword"&gt;IntPtr&lt;/span&gt; errorInfo)
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.&amp;lt;CreateCoreWebView2ControllerAsync&amp;gt;d__80.MoveNext()
--- End of stack trace &lt;span class="code-sdkkeyword"&gt;from&lt;/span&gt; previous location &lt;span class="code-sdkkeyword"&gt;where&lt;/span&gt; exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Web.WebView2.Wpf.WebView2.&amp;lt;&amp;gt;c__DisplayClass32_0.&amp;lt;&amp;lt;EnsureCoreWebView2Async&amp;gt;g__Init|0&amp;gt;d.MoveNext()
2024-05-14 &lt;span class="code-digit"&gt;06&lt;/span&gt;:&lt;span class="code-digit"&gt;34&lt;/span&gt;:&lt;span class="code-digit"&gt;45&lt;/span&gt;.4923|DEBUG|debug|WebView2 initialization failed.mscorlib&lt;/pre&gt;</description>
      <author>Aditi Arora 2021</author>
      <link>https://www.codeproject.com/Messages/6001540/Initialize-Webview2-in-WPF-Application-work-for-wi</link>
      <pubDate>Thu, 16 May 2024 18:05:00 GMT</pubDate>
      <guid>3_6001540</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>Binding Header in TabItem to child property in the ViewModel</title>
      <description>I have a standard C#, WPF, and PRISM project, and I wanted to have one module per tab item. But I want to bind the header of a property in the ViewModel directly to the parent TabItem.&lt;br /&gt;
&lt;br /&gt;
I tried this (among other things such as Content.DataContext.Message etc.) :&lt;br /&gt;
&lt;div class='pre-lang' id='premain327156'&gt;&lt;div&gt;XML&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode327156' class='copy-code' data-index='327156' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre327156' style='margin-top:0;' class='lang-xml' data-language='XML' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;TabItem&lt;/span&gt;&lt;span class="code-attribute"&gt; &lt;/span&gt;&lt;span class="code-attribute"&gt;Header&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;{Binding DataContext.Message, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ContentControl&lt;/span&gt;&lt;span class="code-attribute"&gt; &lt;/span&gt;&lt;span class="code-attribute"&gt;prism:RegionManager.RegionName&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;{x:Static core:RegionNames.ContentRegion}"&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;/ContentControl&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="code-keyword"&gt;&amp;lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;/TabItem&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
I have a distinct feeling I have done this before, but I cannot figure it out at the moment, so any suggestions?</description>
      <author>Kenneth Haugland</author>
      <link>https://www.codeproject.com/Messages/5998901/Binding-Header-in-TabItem-to-child-property-in-the</link>
      <pubDate>Mon, 29 Apr 2024 07:57:00 GMT</pubDate>
      <guid>3_5998901</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>DataGrid Built In ViewModel Question</title>
      <description>I'm building and populating a DataGrid in a viewmodel. &lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://1drv.ms/i/c/8c20f7f8944e1159/EaFv8Hpnk3xCvEdjGQnuo7cBP2zcDTIsV7PdOj3GGPPLGA?e=LFJyVH"&gt;Here's what I'm making&lt;/a&gt;[&lt;a href="https://1drv.ms/i/c/8c20f7f8944e1159/EaFv8Hpnk3xCvEdjGQnuo7cBP2zcDTIsV7PdOj3GGPPLGA?e=LFJyVH" target="_blank"&gt;^&lt;/a&gt;]&lt;br /&gt;
&lt;br /&gt;
The two columns on the right, AutoAdjustment and AutoPosting, are combo boxes where the user can selecte 'Y' or 'N'. These are the only editable columns.&lt;br /&gt;
&lt;br /&gt;
For my source data, I have a list of objects called ProcoessingOutputEntries, each with a list of column objects. It's basically a 'row' object with a dynamic collection of columns on it:
&lt;div class='pre-lang' id='premain68384'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode68384' class='copy-code' data-index='68384' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre68384' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; List&amp;lt;ProcessingOutputEntryEntity&amp;gt; _ProcesssingOutputEntries;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; List&amp;lt;ProcessingOutputEntryEntity&amp;gt; ProcesssingOutputEntries
{
    &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _ProcesssingOutputEntries; }
    &lt;span class="code-keyword"&gt;set&lt;/span&gt;
    {
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_ProcesssingOutputEntries != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)

        {
            _ProcesssingOutputEntries = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
            RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(ProcesssingOutputEntries));
        }
    }
}&lt;/pre&gt;
and
&lt;div class='pre-lang' id='premain522355'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode522355' class='copy-code' data-index='522355' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre522355' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; ProcessingOutputEntryEntity : _EntityBase
{
    &lt;span class="code-keyword"&gt;private&lt;/span&gt; List&amp;lt;ColumnInfoEntity&amp;gt; _ProcesssingOutputColumns;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; List&amp;lt;ColumnInfoEntity&amp;gt; ProcesssingOutputColumns
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _ProcesssingOutputColumns; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_ProcesssingOutputColumns != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _ProcesssingOutputColumns = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(ProcesssingOutputColumns));
            }
        }
    }
}&lt;/pre&gt;
and
&lt;div class='pre-lang' id='premain72769'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode72769' class='copy-code' data-index='72769' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre72769' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; ColumnInfoEntity : _EntityBase
{
    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; _ColumnName;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; ColumnName
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _ColumnName; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_ColumnName != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _ColumnName = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(ColumnName));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; ColumnSources _ColumnSource;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; ColumnSources ColumnSource
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _ColumnSource; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_ColumnSource != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _ColumnSource = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(ColumnSource));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; ColumnTypes _ColumnType;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; ColumnTypes ColumnType
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _ColumnType; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_ColumnType != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _ColumnType = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(ColumnType));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;int&lt;/span&gt; _ColumnWidth;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;int&lt;/span&gt; ColumnWidth
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _ColumnWidth; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_ColumnWidth != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _ColumnWidth = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(ColumnWidth));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; _DisplayAs;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; DisplayAs
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _DisplayAs; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_DisplayAs != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _DisplayAs = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(DisplayAs));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;int&lt;/span&gt; _IndexPosition;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;int&lt;/span&gt; IndexPosition
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _IndexPosition; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_IndexPosition != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _IndexPosition = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(IndexPosition));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;bool&lt;/span&gt; _IsUserEditable = &lt;span class="code-keyword"&gt;true&lt;/span&gt;;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;bool&lt;/span&gt; IsUserEditable
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _IsUserEditable; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_IsUserEditable != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _IsUserEditable = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(IsUserEditable));
            }
        }
    }

    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;object&lt;/span&gt; _Data;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;object&lt;/span&gt; Data
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _Data; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt;
        {
            &lt;span class="code-keyword"&gt;if&lt;/span&gt; (_Data != &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;)
            {
                _Data = &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;;
                RaisePropertyChanged(&lt;span class="code-keyword"&gt;nameof&lt;/span&gt;(Data));
            }
        }
    }

    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;override&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; ToString()
    {
        &lt;span class="code-keyword"&gt;return&lt;/span&gt; $&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{ColumnSource} {IndexPosition} {ColumnName}"&lt;/span&gt;;
    }
}&lt;/pre&gt;
I handle the WindowLoaded event to create the grid in my ViewModel:
&lt;div class='pre-lang' id='premain425678'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode425678' class='copy-code' data-index='425678' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre425678' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; WindowLoadedExecuted()
{
    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; At this point, the row objects don&amp;#39;t have an Id, so create one for each row.&lt;/span&gt;
    _results.ProcesssingOutputEntries.ForEach(x =&amp;gt; x.Id = Guid.NewGuid());

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Now, add an Id column in front of all other columns&lt;/span&gt;
    &lt;span class="code-keyword"&gt;foreach&lt;/span&gt; (&lt;span class="code-keyword"&gt;var&lt;/span&gt; entry &lt;span class="code-keyword"&gt;in&lt;/span&gt; _results.ProcesssingOutputEntries)
    {
        &lt;span class="code-keyword"&gt;var&lt;/span&gt; col = &lt;span class="code-keyword"&gt;new&lt;/span&gt; ColumnInfoEntity
        {
            ColumnName = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Id"&lt;/span&gt;,
            Data = entry.Id.ToString()
        };

        entry.ProcesssingOutputColumns.Insert(&lt;span class="code-digit"&gt;0&lt;/span&gt;, col);
    }

    DataColumn column = &lt;span class="code-keyword"&gt;null&lt;/span&gt;;

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Add data table columns using the column info objects on the first processing object&lt;/span&gt;
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; firstEntry = _results.ProcesssingOutputEntries.FirstOrDefault();
    &lt;span class="code-keyword"&gt;foreach&lt;/span&gt; (&lt;span class="code-keyword"&gt;var&lt;/span&gt; col &lt;span class="code-keyword"&gt;in&lt;/span&gt; firstEntry.ProcesssingOutputColumns)
    {
        column = &lt;span class="code-keyword"&gt;new&lt;/span&gt; DataColumn
        {
            DataType = Type.GetType(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;System.String"&lt;/span&gt;),
            ReadOnly = &lt;span class="code-keyword"&gt;false&lt;/span&gt;
        };
        ColumnsDataTable.Columns.Add(column);
    }

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Get the index positions of the AutoAdjustment and AutoPosting columns, so we can make all&lt;/span&gt;
    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; other columns read-only&lt;/span&gt;
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; autoAdjColIndex = -1;
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; autoPostColIndex = -1;

    &lt;span class="code-keyword"&gt;var&lt;/span&gt; autoAdjCol = GetProcessingOutputColumn(ColumnTypes.AutoAdjustment);

    &lt;span class="code-keyword"&gt;if&lt;/span&gt;(autoAdjCol != &lt;span class="code-keyword"&gt;null&lt;/span&gt;)
    {
        autoAdjColIndex = firstEntry.ProcesssingOutputColumns.IndexOf(autoAdjCol);
    }

    &lt;span class="code-keyword"&gt;var&lt;/span&gt; autoPostCol = GetProcessingOutputColumn(ColumnTypes.AutoPosting);

    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (autoPostCol != &lt;span class="code-keyword"&gt;null&lt;/span&gt;)
    {
        autoPostColIndex = firstEntry.ProcesssingOutputColumns.IndexOf(autoPostCol);
    }

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Get a list of column names from the data table created above&lt;/span&gt;
    string[] columnNames = (&lt;span class="code-sdkkeyword"&gt;from&lt;/span&gt; dc &lt;span class="code-keyword"&gt;in&lt;/span&gt; ColumnsDataTable.Columns.Cast()
                            &lt;span class="code-sdkkeyword"&gt;select&lt;/span&gt; dc.ColumnName).ToArray();

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Create styles for the cells&lt;/span&gt;
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; textBoxStyle = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Style();
    textBoxStyle.Setters.Add(&lt;span class="code-keyword"&gt;new&lt;/span&gt; Setter(TextBox.TextAlignmentProperty, TextAlignment.Right));

    &lt;span class="code-keyword"&gt;var&lt;/span&gt; comboBoxStyle = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Style();
    comboBoxStyle.Setters.Add(&lt;span class="code-keyword"&gt;new&lt;/span&gt; EventSetter(ComboBox.SelectionChangedEvent, &lt;span class="code-keyword"&gt;new&lt;/span&gt; SelectionChangedEventHandler(ComboSelectionChanged)));

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Go through each column&lt;/span&gt;
    &lt;span class="code-keyword"&gt;int&lt;/span&gt; index = &lt;span class="code-digit"&gt;0&lt;/span&gt;;
    &lt;span class="code-keyword"&gt;foreach&lt;/span&gt; (&lt;span class="code-keyword"&gt;string&lt;/span&gt; columnName &lt;span class="code-keyword"&gt;in&lt;/span&gt; columnNames)
    {
        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Create binding&lt;/span&gt;
        &lt;span class="code-keyword"&gt;var&lt;/span&gt; binding = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Binding(columnName);

        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; If the column is the AutoAdjustment or AutoPosting column, add combo box columns&lt;/span&gt;
        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; These two columns will be the right most two&lt;/span&gt;
        &lt;span class="code-keyword"&gt;if&lt;/span&gt; (index == autoAdjColIndex || index == autoPostColIndex)
        {
            &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Add a combo box column for it&lt;/span&gt;
            &lt;span class="code-keyword"&gt;var&lt;/span&gt; col = &lt;span class="code-keyword"&gt;new&lt;/span&gt; DataGridComboBoxColumn()
            {
                Header = firstEntry.ProcesssingOutputColumns[index].ColumnName,
                ItemsSource = &lt;span class="code-keyword"&gt;new&lt;/span&gt; List { &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Y"&lt;/span&gt;, &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;N"&lt;/span&gt; },
                Visibility = Visibility.Visible,
                TextBinding = binding,
                IsReadOnly = &lt;span class="code-keyword"&gt;false&lt;/span&gt;,
                CellStyle = comboBoxStyle,&amp;lt;br /&amp;gt;
            };
            DataGridColumns.Add(col);
        }
        &lt;span class="code-keyword"&gt;else&lt;/span&gt;
        {
            &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Otherwise, add a read-only textbox column for it&lt;/span&gt;
            &lt;span class="code-keyword"&gt;var&lt;/span&gt; col = &lt;span class="code-keyword"&gt;new&lt;/span&gt; DataGridTextColumn()
            {
                Header = firstEntry.ProcesssingOutputColumns[index].ColumnName,
                Binding = binding,
                Visibility = Visibility.Visible,
                IsReadOnly = &lt;span class="code-keyword"&gt;true&lt;/span&gt;,
                CellStyle = textBoxStyle
            };
            DataGridColumns.Add(col);
        }

        index++;
    }

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Hide the first column, the Id&lt;/span&gt;
    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;DataGridColumns.FirstOrDefault().Visibility = Visibility.Hidden;&lt;/span&gt;

    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Load the data into the grid&lt;/span&gt;
    LoadData();
}&lt;/pre&gt;
Here's how the data is loaded
&lt;div class='pre-lang' id='premain715293'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode715293' class='copy-code' data-index='715293' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre715293' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; LoadData()
{
    ColumnsDataTable.Clear();

    &lt;span class="code-keyword"&gt;foreach&lt;/span&gt; (&lt;span class="code-keyword"&gt;var&lt;/span&gt; processingEntry &lt;span class="code-keyword"&gt;in&lt;/span&gt; _results.ProcesssingOutputEntries)
    {
        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Create a new row&lt;/span&gt;
        DataRow row = ColumnsDataTable.NewRow();
        ColumnsDataTable.Rows.Add(row);

        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Add each column&amp;#39;s data&lt;/span&gt;
        &lt;span class="code-keyword"&gt;var&lt;/span&gt; index = &lt;span class="code-digit"&gt;0&lt;/span&gt;;
        &lt;span class="code-keyword"&gt;foreach&lt;/span&gt; (&lt;span class="code-keyword"&gt;var&lt;/span&gt; col &lt;span class="code-keyword"&gt;in&lt;/span&gt; processingEntry.ProcesssingOutputColumns)
        {
            row[index] = col.Data;
            index++;
        }
    }
}&lt;/pre&gt;
The ComboBox column style handles the SelectionChanged event:
&lt;div class='pre-lang' id='premain129771'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode129771' class='copy-code' data-index='129771' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre129771' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;var&lt;/span&gt; comboBoxStyle = &lt;span class="code-keyword"&gt;new&lt;/span&gt; Style();
comboBoxStyle.Setters.Add(&lt;span class="code-keyword"&gt;new&lt;/span&gt; EventSetter(ComboBox.SelectionChangedEvent, &lt;span class="code-keyword"&gt;new&lt;/span&gt; SelectionChangedEventHandler(ComboSelectionChanged)));&lt;/pre&gt;
and
&lt;div class='pre-lang' id='premain539028'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode539028' class='copy-code' data-index='539028' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre539028' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; ComboSelectionChanged(&lt;span class="code-keyword"&gt;object&lt;/span&gt; sender, SelectionChangedEventArgs e)
{
    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Find the selected row&lt;/span&gt;
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; comboBox = e.Source &lt;span class="code-keyword"&gt;as&lt;/span&gt; ComboBox;
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; dataGrid = WPFTools.GetVisualParent(comboBox);
    &lt;span class="code-keyword"&gt;var&lt;/span&gt; dataRowView = dataGrid.SelectedItem &lt;span class="code-keyword"&gt;as&lt;/span&gt; DataRowView;

    &lt;span class="code-keyword"&gt;if&lt;/span&gt;(dataRowView != &lt;span class="code-keyword"&gt;null&lt;/span&gt;)
    {
        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Get the new selection from the combo box. It will be either &amp;#39;Y&amp;#39; or &amp;#39;N&amp;#39;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;var&lt;/span&gt; newSelection = e.AddedItems[0];

        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Get the row&amp;#39;s Id&lt;/span&gt;
        &lt;span class="code-keyword"&gt;var&lt;/span&gt; rowId = dataRowView.Row[0].ToString();
    }
}&lt;/pre&gt;
&lt;br /&gt;
So, the question is, in this event handler, how do I set the newly selected value back to the source row? It seems like I need to get the row, then the bound object from it. But how do I know which combox fired this event?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5996084/DataGrid-Built-In-ViewModel-Question</link>
      <pubDate>Mon, 08 Apr 2024 23:24:00 GMT</pubDate>
      <guid>3_5996084</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>WPF .Net 6</title>
      <description>I'm sure this is a silly question....&lt;br /&gt;
&lt;br /&gt;
I'm trying to port some behaviors from .Net Framewor 4.7 to Core 6.&lt;br /&gt;
&lt;br /&gt;
This no longer compiles:
&lt;div class='pre-lang' id='premain906338'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode906338' class='copy-code' data-index='906338' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre906338' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; ComboBoxWatermarkBehavior : Behavior&amp;lt;ComboBox&amp;gt;
.
.
.&lt;/pre&gt;
because it can't find Behavior&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From what I can see from Google results, I was missing Microsoft.Xaml.Behaviors.Wpf. I added the package but it didn't do anything.&lt;br /&gt;
&lt;br /&gt;
What am I missing here???&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5992581/WPF-Net-6</link>
      <pubDate>Fri, 15 Mar 2024 02:35:00 GMT</pubDate>
      <guid>3_5992581</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>DependencyProperty fires only in ViewModel.ctor</title>
      <description>Hello,&lt;br /&gt;
I'd tried to reduce the problem.&lt;br /&gt;
I've this UserControl&lt;br /&gt;
&lt;div class='pre-lang' id='premain56124'&gt;&lt;div&gt;C#&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode56124' class='copy-code' data-index='56124' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre56124' style='margin-top:0;' class='lang-csharp' data-language='C#' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; TestControl : Label 
{
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;readonly&lt;/span&gt; DependencyProperty dependencyPropertyTestInfo =
        DependencyProperty.Register(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TestInfo"&lt;/span&gt;, &lt;span class="code-keyword"&gt;typeof&lt;/span&gt;(&lt;span class="code-keyword"&gt;string&lt;/span&gt;), &lt;span class="code-keyword"&gt;typeof&lt;/span&gt;(TestControl),
            &lt;span class="code-keyword"&gt;new&lt;/span&gt; PropertyMetadata(&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;"&lt;/span&gt;, &lt;span class="code-keyword"&gt;new&lt;/span&gt; PropertyChangedCallback(ChangeTestInfo)));

    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; TestInfo
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; =&amp;gt; (&lt;span class="code-keyword"&gt;string&lt;/span&gt;)GetValue(dependencyPropertyTestInfo);
        &lt;span class="code-keyword"&gt;set&lt;/span&gt; =&amp;gt; SetValue(dependencyPropertyTestInfo, &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;);
    }
    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;static&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; ChangeTestInfo(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        &lt;span class="code-keyword"&gt;var&lt;/span&gt; testControl = (TestControl)d;
        testControl.TestInfo = (&lt;span class="code-keyword"&gt;string&lt;/span&gt;)e.NewValue;
    }
}&lt;/pre&gt;&lt;br /&gt;
This is the essential part of MainWindow.xaml:&lt;br /&gt;
&lt;div class='pre-lang' id='premain606790'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode606790' class='copy-code' data-index='606790' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre606790' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;StackPanel&amp;gt;
    &amp;lt;local:TestControl Content=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TestControl"&lt;/span&gt; x:Name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;tct"&lt;/span&gt; TestInfo=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding TestInfoView}"&lt;/span&gt;/&amp;gt;
    &amp;lt;Button Content=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;show TestInfo by Button-Click in xaml.cs"&lt;/span&gt; x:Name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;BtnShow"&lt;/span&gt; Click=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;BtnShow_Click"&lt;/span&gt;/&amp;gt;
    &amp;lt;Button Content=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;set new TestInfo"&lt;/span&gt; Name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;BtnNewTestInfo"&lt;/span&gt; Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding NewTestInfoCommand}"&lt;/span&gt;/&amp;gt;
&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
Its bounded in MainWindow.xaml.cs to DataContext with this ViewModel:&lt;br /&gt;
&lt;div class='pre-lang' id='premain20715'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode20715' class='copy-code' data-index='20715' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre20715' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;class&lt;/span&gt; MainWindowViewModel : BindableBase
{
    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;int&lt;/span&gt; counter;
    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; _testInfoView;
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; &lt;span class="code-keyword"&gt;string&lt;/span&gt; TestInfoView
    {
        &lt;span class="code-keyword"&gt;get&lt;/span&gt; { &lt;span class="code-keyword"&gt;return&lt;/span&gt; _testInfoView; }
        &lt;span class="code-keyword"&gt;set&lt;/span&gt; { SetProperty(&lt;span class="code-keyword"&gt;ref&lt;/span&gt; _testInfoView, &lt;span class="code-sdkkeyword"&gt;value&lt;/span&gt;); }
    }
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; DelegateCommand NewTestInfoCommand { &lt;span class="code-keyword"&gt;get&lt;/span&gt;; }
    &lt;span class="code-keyword"&gt;public&lt;/span&gt; MainWindowViewModel()
    {
        NewTestInfoCommand = &lt;span class="code-keyword"&gt;new&lt;/span&gt; DelegateCommand(OnNewTestInfoCommand);
        TestInfoView = &lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Info from ctor"&lt;/span&gt;;
    }
    &lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; OnNewTestInfoCommand()
    {
        &lt;span class="code-keyword"&gt;string&lt;/span&gt; newInfo = $&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Info No. {++counter}"&lt;/span&gt;;
        Debug.WriteLine($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{MethodBase.GetCurrentMethod().Name}: {nameof(TestInfoView)}=&amp;#171;{TestInfoView}&amp;#187; -&amp;gt; &amp;#171;{newInfo}&amp;#187;"&lt;/span&gt;);
        TestInfoView = newInfo;
    }
}&lt;/pre&gt;&lt;br /&gt;
I've added a "Debug.WriteLine" in MainWindow.xaml.cs&lt;br /&gt;
&lt;div class='pre-lang' id='premain416987'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode416987' class='copy-code' data-index='416987' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre416987' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; BtnShow_Click(&lt;span class="code-keyword"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
{
   Debug.WriteLine($&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{MethodBase.GetCurrentMethod().Name}: {nameof(tct.TestInfo)}={tct.TestInfo}"&lt;/span&gt;);
}&lt;/pre&gt;&lt;br /&gt;
After starting the app&lt;br /&gt;
&lt;br /&gt;
1. I've clicked "BtnShow" this is the debug-info:&lt;br /&gt;
BtnShow_Click: TestInfo=Info from ctor&lt;br /&gt;
2. I've clicked "BtnNewTestInfo" this is the debug-info:&lt;br /&gt;
OnNewTestInfoCommand: TestInfoView=«Info from ctor» -&amp;gt; «Info No. 1»&lt;br /&gt;
3. I've clicked "BtnShow" this is the debug-info:&lt;br /&gt;
BtnShow_Click: TestInfo=Info from ctor&lt;br /&gt;
&lt;br /&gt;
Now my question is: why ViewModel-Command doesn't change the content of TestControl?&lt;br /&gt;
&lt;br /&gt;
Explanation of the goal:&lt;br /&gt;
Based on a WrapPanel I'll add in Children ToggleButton as a representation of tags in a Control named "TagPanel". By clicking the ToggleButton I can define the Tags of a given dataset record.&lt;br /&gt;
To define the ToggleButton I'll set in ViewModel a string property "TagDef" with comma-separated values like "red,blue,green" to get three buttons.&lt;br /&gt;
And by setting a string property "CheckedTag" (i.e "green,red") I'll set IsChecked of the concerned buttons.&lt;br /&gt;
&lt;br /&gt;
But by setting in viewmodel, the properties aren't changed in TagPanel. Now I'm using events - what a pity.</description>
      <author>iwangoll</author>
      <link>https://www.codeproject.com/Messages/5989619/DependencyProperty-fires-only-in-ViewModel-ctor</link>
      <pubDate>Sun, 25 Feb 2024 18:34:00 GMT</pubDate>
      <guid>3_5989619</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>Get Tab For Context Menu</title>
      <description>I have a tab control, and I have a header template and style:
&lt;div class='pre-lang' id='premain577204'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode577204' class='copy-code' data-index='577204' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre577204' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;!&lt;strike&gt;Tab Item Header Template&lt;/strike&gt;&amp;gt;
&amp;lt;DataTemplate x:Key=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;CustomHeaderTemplate"&lt;/span&gt;&amp;gt;

    &amp;lt;DockPanel LastChildFill=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;True"&lt;/span&gt;&amp;gt;

        &amp;lt;TextBlock Text=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding FileName}"&lt;/span&gt;
                   VerticalAlignment=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Center"&lt;/span&gt;
                   FontSize=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;14"&lt;/span&gt;/&amp;gt;

        &amp;lt;Button Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding DataContext.CloseTabCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"&lt;/span&gt;
                CommandParameter=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding}"&lt;/span&gt;
                VerticalAlignment=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Center"&lt;/span&gt;
                Height=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;22"&lt;/span&gt;
                Width=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;22"&lt;/span&gt;
                Background=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;SteelBlue"&lt;/span&gt;
                Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;3,0,0,0"&lt;/span&gt;&amp;gt;

            &amp;lt;Path Data=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;M1,9 L9,1 M1,1 L9,9"&lt;/span&gt;
                  Stroke=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;White"&lt;/span&gt;
                  StrokeThickness=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;2"&lt;/span&gt; /&amp;gt;

        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Button&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DockPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&amp;lt;!&lt;strike&gt;Tab Item Style&lt;/strike&gt;&amp;gt;
&amp;lt;Style TargetType=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TabItem"&lt;/span&gt;&amp;gt;

    &amp;lt;Setter Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;ContextMenu"&lt;/span&gt;&amp;gt;
        &amp;lt;Setter.Value&amp;gt;
            &amp;lt;ContextMenu DataContext=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Path=PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}"&lt;/span&gt; &amp;gt;

                &amp;lt;MenuItem Header=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Close Tab"&lt;/span&gt;
                          Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Source={StaticResource Proxy}, Path=Data.CloseTabCommand}"&lt;/span&gt;
                          CommandParameter=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding}"&lt;/span&gt;/&amp;gt;

                &amp;lt;MenuItem Header=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Close All Tabs"&lt;/span&gt;
                          Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Source={StaticResource Proxy}, Path=Data.CloseAllTabsCommand}"&lt;/span&gt;
                          CommandParameter=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding}"&lt;/span&gt;/&amp;gt;

                &amp;lt;MenuItem Header=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Close All But This"&lt;/span&gt;
                          Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Source={StaticResource Proxy}, Path=Data.CloseAllButThisTabCommand}"&lt;/span&gt;
                          CommandParameter=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding}"&lt;/span&gt;/&amp;gt;
            &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ContextMenu&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Setter.Value&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Setter&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Style&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
The problem is that if I right-click a tab that is NOT selected, and choose one of the close options, the SELECTED tab is closed. How can I specify that correct tab item in the command?&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5984646/Get-Tab-For-Context-Menu</link>
      <pubDate>Sat, 27 Jan 2024 05:35:00 GMT</pubDate>
      <guid>3_5984646</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>INotifyDataErrorInfo Question</title>
      <description>I have a window with bound fields that I'm validating with INotifyDataErrorInfo. There is a button on the window that opens a dialog that the user needs to complete before all of the data is truly valid.&lt;br /&gt;
&lt;br /&gt;
What I'd like is to to have a validation message next to the button. But since the button is not bound, I can't really use INotifyDataErrorInfo for this.&lt;br /&gt;
&lt;br /&gt;
What's the right way to do this?&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5980524/INotifyDataErrorInfo-Question</link>
      <pubDate>Wed, 03 Jan 2024 04:07:00 GMT</pubDate>
      <guid>3_5980524</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>When Are All DependencyProperties Set</title>
      <description>I have a CustomControl with three DP's. On startup the change callbacks fire for all three, but I need to know when they have ALL fired, so I can then set up the control using their data. The Initialized gets called first, then the DP's, so I can't rely on that.&lt;br /&gt;
&lt;br /&gt;
I was thinking of creating a bool flag for each, and when each are true, then go ahead and load my control using all the DP's, but I'm wondering if there's another way.&lt;br /&gt;
&lt;br /&gt;
An event that fires AFTER the DP's would be nice, but I don't see one.&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5979959/When-Are-All-DependencyProperties-Set</link>
      <pubDate>Fri, 29 Dec 2023 08:12:00 GMT</pubDate>
      <guid>3_5979959</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>DataTemplate Problem</title>
      <description>I have an app that displays 1 to 16 video player controls. The user can select the type of player (ie LeadTools, VLC) and the number of players to show.&lt;br /&gt;
&lt;br /&gt;
Once the type and number of players is selected, I load the players into the main window's Players collection. The ActiveX player is hosted in a PlayerHostViewl, and that is added to an ObservableCollection&amp;lt;playerhostviewmodel&amp;gt; called 'Players'&lt;br /&gt;
&lt;br /&gt;
Here's the main window's XAML's resources, showing the data template for the collection:
&lt;div class='pre-lang' id='premain735164'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode735164' class='copy-code' data-index='735164' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre735164' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;Window.Resources&amp;gt;

    &amp;lt;DataTemplate DataType=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{x:Type vms:PlayerHostViewModel}"&lt;/span&gt;&amp;gt;
        &amp;lt;vws:PlayerHostView/&amp;gt;
    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window.Resources&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
and the MainWindow's player collection:
&lt;div class='pre-lang' id='premain47233'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode47233' class='copy-code' data-index='47233' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre47233' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;Border Grid.Row=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1"&lt;/span&gt;
        Grid.Column=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;0"&lt;/span&gt;
        BorderThickness=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1"&lt;/span&gt;
        BorderBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;SteelBlue"&lt;/span&gt;
        Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;5,0,0,5"&lt;/span&gt;&amp;gt;

    &amp;lt;ItemsControl ItemsSource=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Players}"&lt;/span&gt;
                    Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;2"&lt;/span&gt;&amp;gt;

        &amp;lt;ItemsControl.ItemsPanel&amp;gt;
            &amp;lt;ItemsPanelTemplate&amp;gt;
                &amp;lt;UniformGrid IsItemsHost=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;True"&lt;/span&gt;
                                Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;2"&lt;/span&gt;/&amp;gt;
            &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsPanelTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsControl.ItemsPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ItemsControl&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Border&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
The MainWindowViewModel's LoadPlayers method:
&lt;div class='pre-lang' id='premain839076'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode839076' class='copy-code' data-index='839076' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre839076' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;private&lt;/span&gt; &lt;span class="code-keyword"&gt;void&lt;/span&gt; LoadPlayers()
{
    &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; If a player type and count are selected...&lt;/span&gt;
    &lt;span class="code-keyword"&gt;if&lt;/span&gt; (SelectedPlayerInfo != &lt;span class="code-keyword"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; SelectedPlayerCount &amp;gt; -1)
    {
        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; For each player to add...&lt;/span&gt;
        &lt;span class="code-keyword"&gt;for&lt;/span&gt; (&lt;span class="code-keyword"&gt;int&lt;/span&gt; i = &lt;span class="code-digit"&gt;0&lt;/span&gt;; i &amp;lt; SelectedPlayerCount + &lt;span class="code-digit"&gt;1&lt;/span&gt;; i++)
        {
            &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Create the player ActiveX control&lt;/span&gt;
            &lt;span class="code-keyword"&gt;var&lt;/span&gt; playerAssembly = (IPlayer)Activator.CreateInstance(SelectedPlayerInfo.PlayerType);

            &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Create the player host&lt;/span&gt;
            &lt;span class="code-keyword"&gt;var&lt;/span&gt; player = &lt;span class="code-keyword"&gt;new&lt;/span&gt; PlayerHostViewModel(playerAssembly, $&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Player {i + 1}"&lt;/span&gt;, LiveStream, DVRStream);

            &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Add the player host to the Players list&lt;/span&gt;
            Players.Add(player);
        }
    }
}&lt;/pre&gt;
Here's the PlayerHost CTORs
&lt;div class='pre-lang' id='premain291099'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode291099' class='copy-code' data-index='291099' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre291099' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;public&lt;/span&gt; PlayerHostViewModel()
{
}
&lt;span class="code-keyword"&gt;public&lt;/span&gt; PlayerHostViewModel(IPlayer player, &lt;span class="code-keyword"&gt;string&lt;/span&gt; playerName, &lt;span class="code-keyword"&gt;string&lt;/span&gt; liveStream, &lt;span class="code-keyword"&gt;string&lt;/span&gt; dvrStream)
{
    Player = player;
    PlayerName = playerName;
    LiveStream = LiveStream;
    DVRStream = dvrStream;  
}&lt;/pre&gt;
The problem is that the PlayerHost paramterized CTOR fires when this line executes, as it should:
&lt;div class='pre-lang' id='premain549697'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode549697' class='copy-code' data-index='549697' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre549697' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-keyword"&gt;var&lt;/span&gt; player = &lt;span class="code-keyword"&gt;new&lt;/span&gt; PlayerHostViewModel(playerAssembly, $&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Player {i + 1}"&lt;/span&gt;, LiveStream, DVRStream);&lt;/pre&gt;
but then the default CTOR fires when this line executes, resetting all the properties the previous CTOR initialed
&lt;div class='pre-lang' id='premain827430'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode827430' class='copy-code' data-index='827430' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre827430' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Add the player host to the Players list&lt;/span&gt;
Players.Add(player);&lt;/pre&gt;
&lt;br /&gt;
I've used DataTemplates in plenty of other apps. I don't understand what's different this time. Anyone see what's wrong?&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5976399/DataTemplate-Problem</link>
      <pubDate>Tue, 05 Dec 2023 23:08:00 GMT</pubDate>
      <guid>3_5976399</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>DataGrid Event Not Firing</title>
      <description>I have a sample app with a AddingNewItem command for a DataGrid, but I can't get it to fire.
&lt;div class='pre-lang' id='premain229723'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode229723' class='copy-code' data-index='229723' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre229723' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;i:Interaction.Triggers&amp;gt;
    &amp;lt;i:EventTrigger EventName=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;AddingNewItem"&lt;/span&gt;&amp;gt;
        &amp;lt;i:InvokeCommandAction Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding DataContext.NewItemAddedCommand, 
            RelativeSource={
                RelativeSource FindAncestor, AncestorType=Window}}"&lt;/span&gt;/&amp;gt;
    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;i:EventTrigger&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
There are no binding errors or other problems. It just doesn't fire. The Setter for the command do fire.&lt;br /&gt;
&lt;br /&gt;
My sample &lt;a href="https://github.com/MaroisConsulting/WPFDataGrid.git"&gt;project is here &lt;/a&gt;[&lt;a href="https://github.com/MaroisConsulting/WPFDataGrid.git" target="_blank"&gt;^&lt;/a&gt;] . Does anyone see what's wrong?&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5975660/DataGrid-Event-Not-Firing</link>
      <pubDate>Fri, 01 Dec 2023 00:11:00 GMT</pubDate>
      <guid>3_5975660</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>DataGrid Exception</title>
      <description>I have a DataGrid that allows users to define CSV file columns for a UI I'm creating. It's bound to an &lt;b&gt;ObservableCollection&amp;lt;columninfoentity&amp;gt;&lt;/b&gt;. I have CanUserAddRows = true. Apparantly setting this to True exposes some strange bug. &lt;br /&gt;
&lt;br /&gt;
The grid's first column has a button:
&lt;div class='pre-lang' id='premain770543'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode770543' class='copy-code' data-index='770543' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre770543' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;DataGrid Grid.Row=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;2"&lt;/span&gt;
          Grid.Column=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;0"&lt;/span&gt;
          ItemsSource=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding ColumnInfos}"&lt;/span&gt;
          HorizontalGridLinesBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;LightGray"&lt;/span&gt;
          VerticalGridLinesBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;LightGray"&lt;/span&gt;
          AutoGenerateColumns=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;False"&lt;/span&gt;
          CanUserAddRows=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;True"&lt;/span&gt;
          CanUserDeleteRows=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;True"&lt;/span&gt;
          CanUserReorderColumns=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;False"&lt;/span&gt;
          CanUserResizeColumns=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;False"&lt;/span&gt;
          CanUserSortColumns=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;False"&lt;/span&gt;
          BorderBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;SteelBlue"&lt;/span&gt;
          BorderThickness=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1"&lt;/span&gt;
          HeadersVisibility=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Column"&lt;/span&gt;
          HorizontalScrollBarVisibility=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Auto"&lt;/span&gt;
          VerticalScrollBarVisibility=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Auto"&lt;/span&gt;
          VerticalAlignment=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Stretch"&lt;/span&gt;
          Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;5,0,5,5"&lt;/span&gt;&amp;gt;

    &amp;lt;DataGrid.Resources&amp;gt;
        &amp;lt;local:BindingProxy x:Key=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;proxy"&lt;/span&gt; Data=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding IsColumnWidthVisibile}"&lt;/span&gt;/&amp;gt;
    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataGrid.Resources&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

    &amp;lt;DataGrid.Columns&amp;gt;

        &amp;lt;DataGridTemplateColumn&amp;gt;
            &amp;lt;DataGridTemplateColumn.CellTemplate&amp;gt;
                &amp;lt;DataTemplate&amp;gt;
                    &amp;lt;Button Command=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding DeleteColumnCommand, RelativeSource={RelativeSource FindAncestor,
                                                                    AncestorLevel=1, AncestorType={x:Type Window}}}"&lt;/span&gt;
                            CommandParameter=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding}"&lt;/span&gt;
                            Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;2"&lt;/span&gt;
                            Height=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;18"&lt;/span&gt;
                            Width=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;18"&lt;/span&gt;/&amp;gt;
                &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataGridTemplateColumn.CellTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataGridTemplateColumn&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

        &amp;lt;DataGridTextColumn Header=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Column Name"&lt;/span&gt;
                            Binding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding ColumnName}"&lt;/span&gt;
                            Width=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;*"&lt;/span&gt;/&amp;gt;

        &amp;lt;DataGridTextColumn Header=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Width"&lt;/span&gt;
                            Binding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding ColumnWidth}"&lt;/span&gt;
                            Width=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;65"&lt;/span&gt;
                            Visibility=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Data, Converter={StaticResource boolToVisibilityConverter}, Source={StaticResource proxy}}"&lt;/span&gt;/&amp;gt;

    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataGrid.Columns&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DataGrid&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
When I enable CanUserAddRows it and run the app I get
&lt;div class='pre-lang' id='premain768724'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode768724' class='copy-code' data-index='768724' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre768724' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
System.InvalidCastException: &lt;span class="code-string"&gt;&amp;#39;&lt;/span&gt;&lt;span class="code-string"&gt;Unable to cast object of type &amp;#39;&lt;/span&gt;MS.Internal.NamedObject&lt;span class="code-string"&gt;&amp;#39;&lt;/span&gt;&lt;span class="code-string"&gt; to type &amp;#39;&lt;/span&gt;WPFDataGrid.ColumnInfoEntity&lt;span class="code-string"&gt;&amp;#39;&lt;/span&gt;&lt;span class="code-string"&gt;.&amp;#39;&lt;/span&gt;&lt;/pre&gt;
Strangly, the exception is thrown in the RelayCommand's CanExecute.&lt;br /&gt;
&lt;br /&gt;
If I comment out the delete button everything works fine.&lt;br /&gt;
&lt;br /&gt;
I created &lt;a href="https://github.com/MaroisConsulting/WPFDataGrid.git"&gt;a sample project&lt;/a&gt;[&lt;a href="https://github.com/MaroisConsulting/WPFDataGrid.git" target="_blank"&gt;^&lt;/a&gt;] to demonstrate this.&lt;br /&gt;
&lt;br /&gt;
I don't understand what the error means, or why I'm getting it. Any help would be great.&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5975277/DataGrid-Exception</link>
      <pubDate>Tue, 28 Nov 2023 22:36:00 GMT</pubDate>
      <guid>3_5975277</guid>
      <subject>WPF</subject>
    </item>
    <item>
      <title>Custom Control Style Question Revisited</title>
      <description>I've asked about this already, but I'm not really getting it. I'm asking this again with more detail in the hopes that it'll make more sense.&lt;br /&gt;
&lt;br /&gt;
Lets say I develop a custom control that have a &lt;a href="https://1drv.ms/i/s!AlkRTpT49yCMm2VqWVdqHEEH-IOD?e=SlqKHJ"&gt;TextBlock over a TextBox&lt;/a&gt;[&lt;a href="https://1drv.ms/i/s!AlkRTpT49yCMm2VqWVdqHEEH-IOD?e=SlqKHJ" target="_blank"&gt;^&lt;/a&gt;]. I have defind colors for Normal and Mouse Over&lt;br /&gt;
&lt;br /&gt;
Here's the XAML for my control. It's pretty simple:
&lt;div class='pre-lang' id='premain241106'&gt;&lt;div&gt;&lt;/div&gt;&lt;div class='pre-action-link'&gt;&lt;span id='copycode241106' class='copy-code' data-index='241106' style='visibility:hidden'&gt;&lt;svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' viewBox='0 0 460 460' style='width: 16px;height:16px;' xml:space='preserve'&gt;&lt;g&gt;&lt;path d='M425.934,0H171.662c-18.122,0-32.864,14.743-32.864,32.864v77.134h30V32.864c0-1.579,1.285-2.864,2.864-2.864h254.272     c1.579,0,2.864,1.285,2.864,2.864v254.272c0,1.58-1.285,2.865-2.864,2.865h-74.729v30h74.729 c18.121,0,32.864-14.743,32.864-32.865V32.864C458.797,14.743,444.055,0,425.934,0z'&gt;&lt;/path&gt;&lt;path d='M288.339,139.998H34.068c-18.122,0-32.865,14.743-32.865,32.865v254.272C1.204,445.257,15.946,460,34.068,460h254.272 c18.122,0,32.865-14.743,32.865-32.864V172.863C321.206,154.741,306.461,139.998,288.339,139.998z M288.341,430H34.068    c-1.58,0-2.865-1.285-2.865-2.864V172.863c0-1.58,1.285-2.865,2.865-2.865h254.272c1.58,0,2.865,1.285,2.865,2.865v254.273h0.001 C291.206,428.715,289.92,430,288.341,430z'&gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre id='pre241106' style='margin-top:0;' data-allowShrink='True' data-collapse='False'&gt;
&amp;lt;pre&amp;gt;&amp;lt;ResourceDictionary xmlns=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;
                    xmlns:x=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;
                    xmlns:local=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;clr-namespace:MyTextBoxEx"&lt;/span&gt;&amp;gt;

&amp;lt;pre&amp;gt;
&amp;lt;SolidColorBrush x:Key=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;CaptionNormalColor"&lt;/span&gt; Color=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Green"&lt;/span&gt;/&amp;gt;
&amp;lt;SolidColorBrush x:Key=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;CaptionMouseOverColor"&lt;/span&gt; Color=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Purple"&lt;/span&gt;/&amp;gt;

&amp;lt;SolidColorBrush x:Key=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TextNormalColor"&lt;/span&gt; Color=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Red"&lt;/span&gt;/&amp;gt;
&amp;lt;SolidColorBrush x:Key=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TextMouseOverColor"&lt;/span&gt; Color=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Blue"&lt;/span&gt;/&amp;gt;

&amp;lt;Style TargetType=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{x:Type local:TextBoxEx}"&lt;/span&gt;&amp;gt;

    &amp;lt;Setter Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Padding"&lt;/span&gt; Value=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;1"&lt;/span&gt;/&amp;gt;

    &amp;lt;Setter Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Template"&lt;/span&gt;&amp;gt;

        &amp;lt;Setter.Value&amp;gt;

            &amp;lt;ControlTemplate TargetType=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{x:Type local:TextBoxEx}"&lt;/span&gt;&amp;gt;

                &amp;lt;StackPanel Orientation=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Vertical"&lt;/span&gt;&amp;gt;

                    &amp;lt;Border Padding=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}"&lt;/span&gt;
                            Margin=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}"&lt;/span&gt;
                            Background=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{TemplateBinding Background}"&lt;/span&gt;
                            BorderBrush=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{TemplateBinding BorderBrush}"&lt;/span&gt;
                            BorderThickness=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{TemplateBinding BorderThickness}"&lt;/span&gt;&amp;gt;

                        &amp;lt;StackPanel Orientation=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Vertical"&lt;/span&gt;&amp;gt;

                            &amp;lt;TextBlock x:Name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;caption"&lt;/span&gt;
                                       Foreground=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{StaticResource CaptionNormalColor}"&lt;/span&gt;
                                       Text=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{TemplateBinding Caption}"&lt;/span&gt;/&amp;gt;

                            &amp;lt;TextBox x:Name=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;text"&lt;/span&gt;
                                     Foreground=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{StaticResource TextNormalColor}"&lt;/span&gt;
                                     Text=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{TemplateBinding Text}"&lt;/span&gt;/&amp;gt;

                        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

                    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Border&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

                &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

                &amp;lt;ControlTemplate.Triggers&amp;gt;

                    &amp;lt;Trigger Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;IsMouseOver"&lt;/span&gt; Value=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;true"&lt;/span&gt;&amp;gt;
                        &amp;lt;Setter TargetName=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;caption"&lt;/span&gt; Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TextElement.Foreground"&lt;/span&gt; Value=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{StaticResource CaptionMouseOverColor}"&lt;/span&gt;/&amp;gt;
                        &amp;lt;Setter TargetName=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;caption"&lt;/span&gt; Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TextElement.FontWeight"&lt;/span&gt; Value=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Bold"&lt;/span&gt;/&amp;gt;

                        &amp;lt;Setter TargetName=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;text"&lt;/span&gt; Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TextElement.Foreground"&lt;/span&gt; Value=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;{StaticResource TextMouseOverColor}"&lt;/span&gt;/&amp;gt;
                        &amp;lt;Setter TargetName=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;text"&lt;/span&gt; Property=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;TextElement.FontStyle"&lt;/span&gt; Value=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Italic"&lt;/span&gt;/&amp;gt;
                    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Trigger&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

                &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ControlTemplate.Triggers&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

            &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ControlTemplate&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Setter.Value&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Setter&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="code-keyword"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Style&lt;/span&gt;&lt;span class="code-keyword"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here's the question. I have assigned colors for normal, and for the Mouse Over triggers. Assume this control was in a compiled assembly, and I gave it to you, how would you go about overwriting the theme colors, or theming it the way you wanted?&lt;br /&gt;
&lt;br /&gt;
When you buy a third party control, and want apply your theme to it, how do the controls inside get their colors set?  In my case, the triggers are set to a specifically named brush. Just knowing the brush names wouldn't help you overwrite the theme colors, would it?&lt;br /&gt;

&lt;div class="signature"&gt;In theory, theory and practice are the same. But in practice, they never are.”&lt;br /&gt;
If it's not broken, fix it until it is.&lt;br /&gt;
Everything makes sense in someone's mind.
&lt;/div&gt;</description>
      <author>Kevin Marois</author>
      <link>https://www.codeproject.com/Messages/5970137/Custom-Control-Style-Question-Revisited</link>
      <pubDate>Mon, 30 Oct 2023 19:14:00 GMT</pubDate>
      <guid>3_5970137</guid>
      <subject>WPF</subject>
    </item>
  </channel>
</rss>