<?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: DependencyProperty not working in derived UserControl in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549331#M14033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmm, I changed to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map", typeof(Map), typeof(DataToolbar), null);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and still the Map is null...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot so far Morten!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 May 2010 16:27:02 GMT</pubDate>
    <dc:creator>RyanCoodey</dc:creator>
    <dc:date>2010-05-18T16:27:02Z</dc:date>
    <item>
      <title>DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549329#M14031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I have been using DependencyProperties on TemplatedControls and had no issues... I am now making a UserControl that is derived from a TemplateControl...&amp;nbsp; The class "Toolbar" is a TemplatedControl and is the base for other toolbars.&amp;nbsp; The class "DataToolbar" is a UserControl derived from "Toolbar", it adds some specific content to the base toolbar and adds a DependencyProperty for a Map control...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the life of me I cannot get the Map property to be anything other than null, it is not binding... any ideas would be great!&amp;nbsp; Thanks... Heres a code snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeBehind:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
public partial class DataToolbar : Toolbar
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Members - Dependency Properties
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected static readonly DependencyProperty dependencyPropertyMap = DependencyProperty.Register("Map", typeof(Map), typeof(DataToolbar), null);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Properties
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Map Map
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return (Map)GetValue(dependencyPropertyMap); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { SetValue(dependencyPropertyMap, value); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;XAML:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;lt;local:DataToolbar x:Name="DataToolbar" Map="{Binding ElementName=MyMap}" /&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 13:17:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549329#M14031</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-05-18T13:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549330#M14032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to follow the guidelines for naming and defining dependency properties. The name and accessibility is important.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Change:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;protected static readonly DependencyProperty dependencyPropertyMap ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to (important changes highlighted):&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;public&lt;/STRONG&gt;&lt;SPAN&gt; static readonly DependencyProperty &lt;/SPAN&gt;&lt;STRONG&gt;MapProperty&lt;/STRONG&gt;&lt;SPAN&gt; ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In other words, the DP must be public and must share the name with the property postfixed with "Property". If it isn't, the binding will not be able to find or access the DP.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 15:18:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549330#M14032</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2010-05-18T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549331#M14033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmm, I changed to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map", typeof(Map), typeof(DataToolbar), null);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and still the Map is null...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot so far Morten!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 16:27:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549331#M14033</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-05-18T16:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549332#M14034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A Question just in case:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Isn't your DataToolbar collapsed?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 16:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549332#M14034</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2010-05-18T16:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549333#M14035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Isn't your DataToolbar collapsed?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nope, its not collapsed.&amp;nbsp; Nothing in the hierarchy of controls in the usercontrol is collapsed either...&amp;nbsp; great idea though, thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 May 2010 17:10:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549333#M14035</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-05-18T17:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549334#M14036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, another thing... putting a break point in the "set" for the property... it never even hits it!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it something to do with it being derived from a TemplateControl maybe?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Map Map
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return (Map)GetValue(MapProperty); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { SetValue(MapProperty, value); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;*EDIT* Also, FYI, I moved the Dependency Property to the base class (TemplateControl) and it doesnt work there either... and also the base class is derived from ContentControl if that matters at all... THANKS!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:46:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549334#M14036</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2021-12-11T23:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549335#M14037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't exactly what's the reason, but it happens in my case as well. I have a window panel inside which I have kept one usercontrol with dependency property. If I set window panel visibility to collapsed , DP doesn't fire and it works when it is visible.. This looks like a bug in window panel may be it is getting inherited from something which doesn't support DP.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 07:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549335#M14037</guid>
      <dc:creator>AnilDhiman</dc:creator>
      <dc:date>2010-05-19T07:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549336#M14038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ryan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The SL framework is not using the CLR accessor, so it's normal that your break points in get/set are never used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What you could test is to define a callback on the property changed and try to put a break point at this level. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Members - Dependency Properties
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected static readonly DependencyProperty dependencyPropertyMap = DependencyProperty.Register("Map", typeof(Map), typeof(DataToolbar), new PropertyMetadata(null, OnMapChanged));

 private static void OnMapChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 { // put a break point here

 }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Properties
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Map Map
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return (Map)GetValue(dependencyPropertyMap); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { SetValue(dependencyPropertyMap, value); }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully this will help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:46:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549336#M14038</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2021-12-11T23:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549337#M14039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;dbroux, thanks a lot for that clarification on the SL framework... I added this callback "OnMapChanged" as you showed and it doesnt appear to ever go in there either &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 17:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549337#M14039</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-05-19T17:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549338#M14040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Oh, another thing... putting a break point in the "set" for the property... it never even hits it! &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When binding a DependencyProperty will never hit the setter. That's why you have the OnMyPropertyChanged handler. In other words your setter should never have anything but the SetValue(MyProperty, value) in it, and for that very reason any logic you need to execute in a setter should happen in the changed handler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure your binding expression is correct and supported? (note that there are limitations as to when and what you can bind to and from - especially when it comes to ElementBinding)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 18:38:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549338#M14040</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2010-05-19T18:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: DependencyProperty not working in derived UserControl</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549339#M14041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Cool, thanks Morten, I don't need any logic to happen, all i need is access to the Map...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what I have found with some tests so far:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;WORKING:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If the DP is in a partial class derived from UserControl, it WORKS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If the DP is in a partial class derived from another partial class which is derived from UserControl, it WORKS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If the DP is in a class derived from ContentControl (with a style defined), it WORKS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (This is what the ESRI toolkit controls do)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NOT WORKING:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If the DP is in a partial class derived from ContentControl (with its content as the other partial class in xaml), it does NOT work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If the DP is in a partial class derived from another partial class which is derived from ContentControl (content in xaml), it does NOT work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- If the DP is in a partial class derived from another class which is derived from ContentControl (with a style defined), it does NOT work&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (This is what I want!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So it seems to be something with the fact that the base class is derived from ContentControl... any ideas?&amp;nbsp; Is this not possible...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 20:52:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/dependencyproperty-not-working-in-derived/m-p/549339#M14041</guid>
      <dc:creator>RyanCoodey</dc:creator>
      <dc:date>2010-05-19T20:52:23Z</dc:date>
    </item>
  </channel>
</rss>

