<?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: Silverlight MultiBindings, How to attached multiple bindings to a single property.</title>
	<atom:link href="http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/</link>
	<description>Colin Eberhardt&#039;s Adventures in WPF</description>
	<lastBuildDate>Tue, 09 Mar 2010 08:51:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Keith Richardson</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/comment-page-1/#comment-7554</link>
		<dc:creator>Keith Richardson</dc:creator>
		<pubDate>Thu, 14 Jan 2010 15:03:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=347#comment-7554</guid>
		<description>Thanks!  You definitely set me down the right path.  I realized that I always modify the collection within functions/properties of the object, so I created a &quot;dummy&quot; property that&#039;s job was to raise a changed notification and added it as another binding to my multi binding.  I never use the value returned by the dummy property, but it make it call the converter, so it updates the values.  If I modified the collection outside of the class, I would need to do a bit more work, but this is fine for now.  Thanks again!

-Keith</description>
		<content:encoded><![CDATA[<p>Thanks!  You definitely set me down the right path.  I realized that I always modify the collection within functions/properties of the object, so I created a &#8220;dummy&#8221; property that&#8217;s job was to raise a changed notification and added it as another binding to my multi binding.  I never use the value returned by the dummy property, but it make it call the converter, so it updates the values.  If I modified the collection outside of the class, I would need to do a bit more work, but this is fine for now.  Thanks again!</p>
<p>-Keith</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Eberhardt</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/comment-page-1/#comment-7335</link>
		<dc:creator>Colin Eberhardt</dc:creator>
		<pubDate>Sat, 09 Jan 2010 06:46:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=347#comment-7335</guid>
		<description>Hi Keith,

Bindings for collection types are &#039;special&#039;!

Regular, single valued bindings depend on the source implementing INotifyPropertyChanged, collection binding depend on INotifyCollectionChanged. To bind a collection you must use one of the controls that inheirt from ItemsControl and bind the collection to its ItemsSource property. These controls consume the events from the INotifyCollectionChanged interface and can react to items being added / removed. Properties other than ItemsSource cannot be used for collection binding.

To solve your problem, I would create a view model that wraps your collection, reacts to items being added / changed / removed, and creates the value that you require for your binding.

Regards, Colin E.</description>
		<content:encoded><![CDATA[<p>Hi Keith,</p>
<p>Bindings for collection types are &#8217;special&#8217;!</p>
<p>Regular, single valued bindings depend on the source implementing INotifyPropertyChanged, collection binding depend on INotifyCollectionChanged. To bind a collection you must use one of the controls that inheirt from ItemsControl and bind the collection to its ItemsSource property. These controls consume the events from the INotifyCollectionChanged interface and can react to items being added / removed. Properties other than ItemsSource cannot be used for collection binding.</p>
<p>To solve your problem, I would create a view model that wraps your collection, reacts to items being added / changed / removed, and creates the value that you require for your binding.</p>
<p>Regards, Colin E.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Richardson</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/comment-page-1/#comment-7259</link>
		<dc:creator>Keith Richardson</dc:creator>
		<pubDate>Wed, 06 Jan 2010 17:22:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=347#comment-7259</guid>
		<description>Hello,

Thanks for the excellent contribution to Silverlight.  This is working great for me for simple fields, like a string, but I&#039;m having a problem if I try to bind to an observablecollection.  I have a class that contains an observable collection among other properties.  I would like to bind, for example, a listbox to an observable collection of this class.  I can do this and then use multi-binding to bind to a string property in the class and it sees all changes to this property.  However, if I bind to the observable collection in that class, it fires the converter one time, but ignores any modifications to the collection.  Do you have any idea what is wrong or where to start looking to fix this?  Thanks for any help you can provide.

-Keith</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thanks for the excellent contribution to Silverlight.  This is working great for me for simple fields, like a string, but I&#8217;m having a problem if I try to bind to an observablecollection.  I have a class that contains an observable collection among other properties.  I would like to bind, for example, a listbox to an observable collection of this class.  I can do this and then use multi-binding to bind to a string property in the class and it sees all changes to this property.  However, if I bind to the observable collection in that class, it fires the converter one time, but ignores any modifications to the collection.  Do you have any idea what is wrong or where to start looking to fix this?  Thanks for any help you can provide.</p>
<p>-Keith</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The mini-ViewModel pattern &#8211; Colin Eberhardt&#8217;s Adventures in WPF</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/comment-page-1/#comment-2645</link>
		<dc:creator>The mini-ViewModel pattern &#8211; Colin Eberhardt&#8217;s Adventures in WPF</dc:creator>
		<pubDate>Fri, 07 Aug 2009 16:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=347#comment-2645</guid>
		<description>[...] Silverlight MultiBindings, How to attached multiple bindings to a single property.   I am a WPF Disciple  Community Credit Winner [...]</description>
		<content:encoded><![CDATA[<p>[...] Silverlight MultiBindings, How to attached multiple bindings to a single property.   I am a WPF Disciple  Community Credit Winner [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Eberhardt</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2009/06/silverlight-multibindings-how-to-attached-mutiple-bindings-to-a-single-property/comment-page-1/#comment-2124</link>
		<dc:creator>Colin Eberhardt</dc:creator>
		<pubDate>Fri, 10 Jul 2009 12:53:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=347#comment-2124</guid>
		<description>Hi Remco,

Try the following modification to BindingUtil ...

&lt;pre&gt;
private static void OnMultiBindingChanged(DependencyObject depObj,
  DependencyPropertyChangedEventArgs e)
{
  FrameworkElement targetElement = depObj as FrameworkElement;

  // bind the target elements DataContext, to our DataContextPiggyBack property
  // this allows us to get property changed events when the targetElement
  // DataContext changes
  targetElement.SetBinding(BindingUtil.DataContextPiggyBackProperty, new Binding());

  MultiBinding relay = GetMultiBinding(targetElement);
  relay.Initialise();

  // find the target dependency property
  Type targetType = null;
  string targetProperty = null;

  // assume it is an attached property if the dot syntax is used.
  if (relay.TargetProperty.Contains(&quot;.&quot;))
  {
      // split to find the type and property name
      string[] parts = relay.TargetProperty.Split(&#039;.&#039;);
      targetType = Type.GetType(&quot;System.Windows.Controls.&quot; + parts[0] +
        &quot;, System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&quot;);
      targetProperty = parts[1];
  }
  else
  {
      targetType = targetElement.GetType();
      targetProperty = relay.TargetProperty;
  }

  FieldInfo[] sourceFields = targetType.GetFields(dpFlags);
  FieldInfo targetDependencyPropertyField =
        sourceFields.First(i =&gt; i.Name == targetProperty + &quot;Property&quot;);
  DependencyProperty targetDependencyProperty =
      targetDependencyPropertyField.GetValue(null) as DependencyProperty;

  // bind the ConvertedValue of our MultiBinding instance to the target property
  // of our targetElement
  Binding binding = new Binding(&quot;ConvertedValue&quot;);
  binding.Source = relay;
  targetElement.SetBinding(targetDependencyProperty, binding);
}&lt;/pre&gt;

This assumes that if you have an attached property, the type &#039;Canvas&#039; comes before the dot. From this we locate the Canvas Type, and use the part after the dot &#039;Left&#039;, to locate the required dependency property. I have tested in in my code by binding the resulting text to the ToolTipService.ToolTip attached property - it works just fine :-)

Regards, Colin E.</description>
		<content:encoded><![CDATA[<p>Hi Remco,</p>
<p>Try the following modification to BindingUtil &#8230;</p>
<pre>
private static void OnMultiBindingChanged(DependencyObject depObj,
  DependencyPropertyChangedEventArgs e)
{
  FrameworkElement targetElement = depObj as FrameworkElement;

  // bind the target elements DataContext, to our DataContextPiggyBack property
  // this allows us to get property changed events when the targetElement
  // DataContext changes
  targetElement.SetBinding(BindingUtil.DataContextPiggyBackProperty, new Binding());

  MultiBinding relay = GetMultiBinding(targetElement);
  relay.Initialise();

  // find the target dependency property
  Type targetType = null;
  string targetProperty = null;

  // assume it is an attached property if the dot syntax is used.
  if (relay.TargetProperty.Contains("."))
  {
      // split to find the type and property name
      string[] parts = relay.TargetProperty.Split('.');
      targetType = Type.GetType("System.Windows.Controls." + parts[0] +
        ", System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e");
      targetProperty = parts[1];
  }
  else
  {
      targetType = targetElement.GetType();
      targetProperty = relay.TargetProperty;
  }

  FieldInfo[] sourceFields = targetType.GetFields(dpFlags);
  FieldInfo targetDependencyPropertyField =
        sourceFields.First(i =&gt; i.Name == targetProperty + "Property");
  DependencyProperty targetDependencyProperty =
      targetDependencyPropertyField.GetValue(null) as DependencyProperty;

  // bind the ConvertedValue of our MultiBinding instance to the target property
  // of our targetElement
  Binding binding = new Binding("ConvertedValue");
  binding.Source = relay;
  targetElement.SetBinding(targetDependencyProperty, binding);
}</pre>
<p>This assumes that if you have an attached property, the type &#8216;Canvas&#8217; comes before the dot. From this we locate the Canvas Type, and use the part after the dot &#8216;Left&#8217;, to locate the required dependency property. I have tested in in my code by binding the resulting text to the ToolTipService.ToolTip attached property &#8211; it works just fine <img src='http://www.scottlogic.co.uk/blog/colin/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Regards, Colin E.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
