<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: WPF with datagrid in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9239757#M37493</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Here is my simple conclusion:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Your code is not MVVM.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's suppose that you have the cell that you are visiting has not yet been displayed on the screen (not yet rendered).&lt;/P&gt;&lt;P&gt;In WPF DataGrid control ( as well as most other controls),&lt;STRONG&gt; data won't be prepared before rendering&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Think abt it in another way. Bind &lt;STRONG&gt;DataGrid.ItemsSource&lt;/STRONG&gt; property to a&lt;STRONG&gt; IEnumerable&amp;lt;T&amp;gt; collection property in your view model&lt;/STRONG&gt;, then each single item has already been prepared whether the DataGrid control having been rendered or not.&lt;/P&gt;&lt;P&gt;The spirit of MVVM is that both &lt;STRONG&gt;the view and the view model can run without knowing each other&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Which means that you should *&lt;STRONG&gt;NEVER&lt;/STRONG&gt;* visit DataGridCell.Content to get a TextBox.Text data. You should &lt;STRONG&gt;directly visit the collection property in you view model&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;It's a gap for developers from WinForm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jan 2020 10:06:47 GMT</pubDate>
    <dc:creator>jlpgy</dc:creator>
    <dc:date>2020-01-09T10:06:47Z</dc:date>
    <item>
      <title>WPF with datagrid</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9239732#M37492</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am starting change Winform to WPF.&lt;/P&gt;&lt;P&gt;I have datagrid with abou 50 fields from Revit.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But I can't read some field currently invisible in datagrid. (visible when I scroll down)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TextBlock item= datagrid1.Columns[2].GetCellContent(datagrid1.Items[15]) as TextBlock;
            MessageBox.Show(item.Text);&lt;/PRE&gt;&lt;P&gt;this make error in revit...&lt;/P&gt;&lt;P&gt;but if I scroll to item 15 and click - it work correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks..&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 09:49:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9239732#M37492</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2020-01-09T09:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: WPF with datagrid</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9239757#M37493</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Here is my simple conclusion:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Your code is not MVVM.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's suppose that you have the cell that you are visiting has not yet been displayed on the screen (not yet rendered).&lt;/P&gt;&lt;P&gt;In WPF DataGrid control ( as well as most other controls),&lt;STRONG&gt; data won't be prepared before rendering&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Think abt it in another way. Bind &lt;STRONG&gt;DataGrid.ItemsSource&lt;/STRONG&gt; property to a&lt;STRONG&gt; IEnumerable&amp;lt;T&amp;gt; collection property in your view model&lt;/STRONG&gt;, then each single item has already been prepared whether the DataGrid control having been rendered or not.&lt;/P&gt;&lt;P&gt;The spirit of MVVM is that both &lt;STRONG&gt;the view and the view model can run without knowing each other&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Which means that you should *&lt;STRONG&gt;NEVER&lt;/STRONG&gt;* visit DataGridCell.Content to get a TextBox.Text data. You should &lt;STRONG&gt;directly visit the collection property in you view model&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;It's a gap for developers from WinForm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 10:06:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9239757#M37493</guid>
      <dc:creator>jlpgy</dc:creator>
      <dc:date>2020-01-09T10:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: WPF with datagrid</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9245182#M37494</link>
      <description>&lt;P&gt;thanks much&lt;/P&gt;&lt;P&gt;...thats look like as web system Joomla or Wordpress.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It so different Winform and WPF.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 22:24:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-with-datagrid/m-p/9245182#M37494</guid>
      <dc:creator>sonicer</dc:creator>
      <dc:date>2020-01-11T22:24:15Z</dc:date>
    </item>
  </channel>
</rss>

