<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How can I have an independent view when my source is ADO.NET?</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=39" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=39</link>
	<description>on Silverlight and WPF</description>
	<lastBuildDate>Mon, 02 Aug 2010 17:57:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-52</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 17 Jan 2007 02:49:35 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-52</guid>
		<description>Hi John,

I personally prefer to do as much as I can in templates, to have as much as possible in XAML. Sometimes you need more flexibility than what we offer within templates, and in that case I value converters are the best option. This may be your situation. 

Blend creates DynamicResources most of the time to allow swapping of resource dictionaries at runtime. If you need this feature, then you should keep that code, otherwise you can have a slight performance improvement by using StaticResources.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi John,</p>
<p>I personally prefer to do as much as I can in templates, to have as much as possible in XAML. Sometimes you need more flexibility than what we offer within templates, and in that case I value converters are the best option. This may be your situation. </p>
<p>Blend creates DynamicResources most of the time to allow swapping of resource dictionaries at runtime. If you need this feature, then you should keep that code, otherwise you can have a slight performance improvement by using StaticResources.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Eyles</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-50</link>
		<dc:creator>John Eyles</dc:creator>
		<pubDate>Tue, 16 Jan 2007 09:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-50</guid>
		<description>Thanks Beatriz (re databinding an animated panel). Dan Crevier suggested using a Value Converter to convert from a DataRowView to MyCustomItem. I can do it for the entire dataset (and convert it to a collection of myCustomItem), but is it possible to apply a Value Converter to individual items loaded (to change their type) and keep the ItemsControl bound to a dataset? Funny enough, the dynamic resource tags where generated by Expression Blend. I&#039;ve just been lazy :) Cheers, John Eyles.</description>
		<content:encoded><![CDATA[<p>Thanks Beatriz (re databinding an animated panel). Dan Crevier suggested using a Value Converter to convert from a DataRowView to MyCustomItem. I can do it for the entire dataset (and convert it to a collection of myCustomItem), but is it possible to apply a Value Converter to individual items loaded (to change their type) and keep the ItemsControl bound to a dataset? Funny enough, the dynamic resource tags where generated by Expression Blend. I&#8217;ve just been lazy :) Cheers, John Eyles.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-48</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Tue, 16 Jan 2007 02:49:55 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-48</guid>
		<description>Hi,

Regarding your question about the animated panel bound to an ADO.NET DataTable. If I understand correctly, you want a handle to your custom control instances so that you can set event handlers on those.

If you have your custom controls in a DataTemplate (which I&#039;m assuming is your scenario), I don&#039;t think you can add a handler to the event directly, but you can use an EventSetter to do that. You can read up more on EventSetters &lt;a href=&quot;http://msdn2.microsoft.com/en-gb/library/system.windows.eventsetter.aspx&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

It&#039;s true that when you read the Items property of ItemsControl you get items from the actual data collection, and not the visuals created to wrap the data. This is actually the intended design. &lt;a href=&quot;http://www.beacosta.com/Archive/2005_09_01_bcosta_archive.html&quot; rel=&quot;nofollow&quot;&gt;Here &lt;/a&gt;you can find a couple of blog posts where I explained how to get to the ComboBoxItem/ListBoxItem when all you have is the data item. In your case, since you&#039;re using an ItemsControl, the generated item that is wrapping your custom control is a ContentPresenter (and not a ListBoxItem or ComboBoxItem like in my earlier blog samples).

I noticed that you are using DynamicResources in your XAML. Are your templates being swapped at runtime? If not, StaticResource is a better choice because it will give you better performance.

Hope this helps.
Bea</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Regarding your question about the animated panel bound to an ADO.NET DataTable. If I understand correctly, you want a handle to your custom control instances so that you can set event handlers on those.</p>
<p>If you have your custom controls in a DataTemplate (which I&#8217;m assuming is your scenario), I don&#8217;t think you can add a handler to the event directly, but you can use an EventSetter to do that. You can read up more on EventSetters <a href="http://msdn2.microsoft.com/en-gb/library/system.windows.eventsetter.aspx" rel="nofollow">here</a>.</p>
<p>It&#8217;s true that when you read the Items property of ItemsControl you get items from the actual data collection, and not the visuals created to wrap the data. This is actually the intended design. <a href="http://www.beacosta.com/Archive/2005_09_01_bcosta_archive.html" rel="nofollow">Here </a>you can find a couple of blog posts where I explained how to get to the ComboBoxItem/ListBoxItem when all you have is the data item. In your case, since you&#8217;re using an ItemsControl, the generated item that is wrapping your custom control is a ContentPresenter (and not a ListBoxItem or ComboBoxItem like in my earlier blog samples).</p>
<p>I noticed that you are using DynamicResources in your XAML. Are your templates being swapped at runtime? If not, StaticResource is a better choice because it will give you better performance.</p>
<p>Hope this helps.<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Eyles</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-47</link>
		<dc:creator>John Eyles</dc:creator>
		<pubDate>Mon, 15 Jan 2007 11:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-47</guid>
		<description>Hi Beatriz.

I&#039;m trying to databind an animating panel to an ADO.NET datatable. Each item in the panel is represented by a custom control, which I have to hook events to (mouse enter, mouse leave). Additionally, the custom controls change color, opacity etc based on the underlying data. If I bind an ItemsControl to a DataSet, the Items property returns a data row view collection, which I can’t hook events to. Do I need to load the dataset data into an observable collection before binding it to the ItemsControl? Otherwise what is the best way of accessing the items generated by the ItemsControl as MyCustomItem type?

I am setting the data context in code behind (as per your blogs – thanks!), and setting the custom control type and visual tree of each item in a data template. 

ItemsControl ItemsSource=&quot;{Binding}&quot; x:Name=&quot;lstItems&quot; ItemTemplate=&quot;{DynamicResource DataTemplate1}&quot; ItemsPanel=&quot;{DynamicResource ItemsPanelTemplate1}&quot;</description>
		<content:encoded><![CDATA[<p>Hi Beatriz.</p>
<p>I&#8217;m trying to databind an animating panel to an ADO.NET datatable. Each item in the panel is represented by a custom control, which I have to hook events to (mouse enter, mouse leave). Additionally, the custom controls change color, opacity etc based on the underlying data. If I bind an ItemsControl to a DataSet, the Items property returns a data row view collection, which I can’t hook events to. Do I need to load the dataset data into an observable collection before binding it to the ItemsControl? Otherwise what is the best way of accessing the items generated by the ItemsControl as MyCustomItem type?</p>
<p>I am setting the data context in code behind (as per your blogs – thanks!), and setting the custom control type and visual tree of each item in a data template. </p>
<p>ItemsControl ItemsSource=&#8221;{Binding}&#8221; x:Name=&#8221;lstItems&#8221; ItemTemplate=&#8221;{DynamicResource DataTemplate1}&#8221; ItemsPanel=&#8221;{DynamicResource ItemsPanelTemplate1}&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-49</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Mon, 15 Jan 2007 02:59:56 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-49</guid>
		<description>Hi Ivan,

There are several issues with binding to DataView today, due to the way this class was implemented. I explained one of consequences of that implementation (and workaround) in this post, and it seems to me like you&#039;re hitting another one.

I will make sure that we have a bug tracking that issue. Thanks a lot for reporting this!

Bea</description>
		<content:encoded><![CDATA[<p>Hi Ivan,</p>
<p>There are several issues with binding to DataView today, due to the way this class was implemented. I explained one of consequences of that implementation (and workaround) in this post, and it seems to me like you&#8217;re hitting another one.</p>
<p>I will make sure that we have a bug tracking that issue. Thanks a lot for reporting this!</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-51</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Mon, 15 Jan 2007 02:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-51</guid>
		<description>Hi Krijn,

Well, you just found a bug, and a workaround for that bug. :) I was able to repro the bad behavior you described (which is independent of the dialog box). Thanks a lot for reporting this issue, I really appreciate it!

Bea</description>
		<content:encoded><![CDATA[<p>Hi Krijn,</p>
<p>Well, you just found a bug, and a workaround for that bug. :) I was able to repro the bad behavior you described (which is independent of the dialog box). Thanks a lot for reporting this issue, I really appreciate it!</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan (elgoog)</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-46</link>
		<dc:creator>Ivan (elgoog)</dc:creator>
		<pubDate>Sun, 14 Jan 2007 11:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-46</guid>
		<description>Hello Beatriz, 

I have folowing scenario... 
One DataTable, 2 ListViews bind to two new DataRowViews of mentioned DataTable. Both ListViews are set to SelectionMode.Single. DataTables have diferent Filter depending on Date so they are presenting different rows. 

And following problem...
When performing dragdrop functionality Selection is not working properly. Since I dropped item &quot;From one Date&quot; &quot;To another Date&quot; I change the row.Date property and use following ...

foreach (DataRowView drv in row.Table.DefaultView)
{
if (row == drv.Row)
{
lv.SelectedItem = drv;
lv.ScrollIntoView(drv);
break;
}
}

As expected this selects and brings new row into view... But, all previously selected rows remain selected.
lv.UnselectAll() does not work, and DataRowView does not have Selected property...

Am I missing something?

Best regards, Ivan</description>
		<content:encoded><![CDATA[<p>Hello Beatriz, </p>
<p>I have folowing scenario&#8230;<br />
One DataTable, 2 ListViews bind to two new DataRowViews of mentioned DataTable. Both ListViews are set to SelectionMode.Single. DataTables have diferent Filter depending on Date so they are presenting different rows. </p>
<p>And following problem&#8230;<br />
When performing dragdrop functionality Selection is not working properly. Since I dropped item &#8220;From one Date&#8221; &#8220;To another Date&#8221; I change the row.Date property and use following &#8230;</p>
<p>foreach (DataRowView drv in row.Table.DefaultView)<br />
{<br />
if (row == drv.Row)<br />
{<br />
lv.SelectedItem = drv;<br />
lv.ScrollIntoView(drv);<br />
break;<br />
}<br />
}</p>
<p>As expected this selects and brings new row into view&#8230; But, all previously selected rows remain selected.<br />
lv.UnselectAll() does not work, and DataRowView does not have Selected property&#8230;</p>
<p>Am I missing something?</p>
<p>Best regards, Ivan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: krijn</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-45</link>
		<dc:creator>krijn</dc:creator>
		<pubDate>Sat, 13 Jan 2007 04:29:24 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-45</guid>
		<description>.. unless I Refresh the DataView manually after the EndEdit call :

CollectionViewSource.GetDefaultView(rowView.DataView).Refresh()</description>
		<content:encoded><![CDATA[<p>.. unless I Refresh the DataView manually after the EndEdit call :</p>
<p>CollectionViewSource.GetDefaultView(rowView.DataView).Refresh()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: krijn</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-44</link>
		<dc:creator>krijn</dc:creator>
		<pubDate>Sat, 13 Jan 2007 04:27:16 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-44</guid>
		<description>Hi

It seems that editing one DataRow (DataRowView at runtime) inside another Dialog doesn&#039;t work for more then one value by using BeginEdit, CancelEdit or EndEdit.

Steps taken :
1.ListBox with itemssource = EmployeesDataTable and simple DataTemplate
2. EditEmployeeDialog with ShowDialog(dataContext) 
3. code to show the Dialog :
dataRowView.BeginEdit
if dialog.ShowDialog(dataRowView) ..
dialog.EndEdit

Although data inside the DataRow is changed the UI doesn&#039;t get updated correctly ..
Unless I only edit one particular field !

Have you any idea what problem is causing this behavior ?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>It seems that editing one DataRow (DataRowView at runtime) inside another Dialog doesn&#8217;t work for more then one value by using BeginEdit, CancelEdit or EndEdit.</p>
<p>Steps taken :<br />
1.ListBox with itemssource = EmployeesDataTable and simple DataTemplate<br />
2. EditEmployeeDialog with ShowDialog(dataContext)<br />
3. code to show the Dialog :<br />
dataRowView.BeginEdit<br />
if dialog.ShowDialog(dataRowView) ..<br />
dialog.EndEdit</p>
<p>Although data inside the DataRow is changed the UI doesn&#8217;t get updated correctly ..<br />
Unless I only edit one particular field !</p>
<p>Have you any idea what problem is causing this behavior ?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=39&#038;cpage=1#comment-43</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 12 Jan 2007 20:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=39#comment-43</guid>
		<description>Good to know you found the answer.
Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Good to know you found the answer.<br />
Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
</channel>
</rss>
