<?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 How to set FixedAspectRatio to False for Legend in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17324#M403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm creating a legend. I want to set IBoundsProperties.FixedAspectRatio to False. When I run the code, I get "The method or operation is not implemented."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code snippet (C#):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;ILegend2 legend = mapSurroundFrame.MapSurround as ILegend2;
IBoundsProperties bounds = legend as IBoundsProperties;
bounds.FixedAspectRatio = false;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the same error if I cast to IBoundsProperties from the mapSurroundFrame object instead of the legend object.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Jun 2014 15:50:47 GMT</pubDate>
    <dc:creator>TimWhiteaker</dc:creator>
    <dc:date>2014-06-25T15:50:47Z</dc:date>
    <item>
      <title>How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17324#M403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm creating a legend. I want to set IBoundsProperties.FixedAspectRatio to False. When I run the code, I get "The method or operation is not implemented."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code snippet (C#):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;ILegend2 legend = mapSurroundFrame.MapSurround as ILegend2;
IBoundsProperties bounds = legend as IBoundsProperties;
bounds.FixedAspectRatio = false;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the same error if I cast to IBoundsProperties from the mapSurroundFrame object instead of the legend object.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 15:50:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17324#M403</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2014-06-25T15:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17325#M404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;When I run the code, I get "The method or operation is not implemented."&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is because the method is not implemented on the ILengend2 interface, nor is it on the ILegend interface.&amp;nbsp; Look at the API.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-java/api/arcobjects/com/esri/arcgis/carto/ILegend2.html"&gt;http://resources.arcgis.com/en/help/arcobjects-java/api/arcobjects/com/esri/arcgis/carto/ILegend2.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that's not a C# link, but you should get the same results looking at that documentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need a concrete Legend object to call fixedAspectRatio.&amp;nbsp; The Legend class implements that behavior, not the interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Program to an interface" doesn't literally mean, only use Interface types.&amp;nbsp; At some point, you need to instantiate a concrete class for certain behavior.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 17:59:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17325#M404</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2014-06-25T17:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17326#M405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You need a concrete Legend object to call fixedAspectRatio. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the fast response.&amp;nbsp; mapSurroundFrame.MapSurround returns an instance of the Legend coclass, so that should be a concrete object. I've continued digging into this problem and found that when I create a legend manually through the ArcMap GUI, I see that the checkbox for Preserve Aspect Ratio is disabled, so I'm guessing that changing it is not implemented for legends.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For more background, I followed the example here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000006w000000"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000006w000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When instantiated, a legend includes all layers in the map, so I then remove some of them. This changes the size of the legend that you see on screen. However, when you look at the properties for the legend's map surround frame, it still has its original width and height as generated in the code. This makes aligning and distributing the legend element with other elements problematic.&amp;nbsp; Even changing the anchor point through the GUI can result in unwanted resizing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I haven't attempted yet but may try is using IQuerySize to get the updated size in points for the legend, convert to page layout units, and assign that as the new geometry for the map surround frame element. This would help with manual positioning as long as the legend isn't edited, but after it is edited, I think it will still keep the last size as set by the code instead of responding appropriately to resizing through the GUI.&amp;nbsp; But that seems like a kluge (if it even works) so I'm hoping you or another expert on here knows of a better way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 18:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17326#M405</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2014-06-25T18:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17327#M406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What I haven't attempted yet but may try is using IQuerySize to get the updated size in points for the legend, convert to page layout units, and assign that as the new geometry for the map surround frame element.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That seemed to work.&amp;nbsp; Here's some C# code to handle reassigning the geometry to the element.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Update size of element containing the legend
// av is IActiveView on an instance of the page layout
IQuerySize querySize = mapSurroundFrame.MapSurround as IQuerySize;
Double w = 0;
Double h = 0;
querySize.QuerySize(ref w, ref h);
// Convert from points to page units, e.g., inches
w = av.ScreenDisplay.DisplayTransformation.FromPoints(w);
h = av.ScreenDisplay.DisplayTransformation.FromPoints(h);
IEnvelope envelope = new EnvelopeClass();
// The legend is anchored at x=1 inch, y=2 inch on the layout
envelope.PutCoords(1, 2, (1 + w), (2 + h));
IElement element = mapSurroundFrame as IElement;
element.Geometry = envelope;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;----------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For completeness, here are some other things I tried which didn't work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ILegend.Refresh() -- I think that just helps the legend redraw on screen if you changed it programmatically. It didn't fix the geometry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ILegend.QueryBounds -- Unlike on IElement, this QueryBounds method takes an old envelope and a new one. I thought the new one might be the correct geometry. Indeed the is returned from the method with a different size than the old envelope. However, assigning the new envelope as the element's geometry didn't solve the problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17327#M406</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2021-12-10T20:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17328#M407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;mapSurroundFrame.MapSurround returns an &lt;STRONG&gt;&lt;SPAN style="text-decoration:underline;"&gt;i&lt;/SPAN&gt;nstance of the Legend coclass&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Really?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think it says that exactly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looking at the .NET documentation for IMapSurroundFrame Interface:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/001200000m4w000000.htm"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/001200000m4w000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Click on the MapSurround member link.. at the bottom it says:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;"The &lt;STRONG&gt;MapSurround&lt;/STRONG&gt; property allows you to retrieve or set the surround object (north arrow, legend, or scale bar) stored within the frame."&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;&amp;nbsp; You are getting a "surround object" that is stored within the frame, it could be any of the CoClasses that implement the IMapSurround Interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Look at all the "concrete" CoClasses that implement the IMapSurround Interface:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/001200000m47000000.htm"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0012/001200000m47000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not current on my .NET ArcObjects, but it seems to me that you still need an instance of a Legend CoClass somewhere.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 20:00:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17328#M407</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2014-06-25T20:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17329#M408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I see the source of confusion.&amp;nbsp; I should have provided more code in my example.&amp;nbsp; Below is a&amp;nbsp; more fully fleshed-out example, showing how the legend is initialized by creating a MapSurroundFrame with UID "esriCarto.Legend".&amp;nbsp; Today I also discovered that I needed to add the element to the layout after I'm finished working with the legend.&amp;nbsp; Otherwise, if I mess with the legend and try to reassign its geometry, the new geometry doesn't stick.&amp;nbsp; It keeps the original one. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Initialize a legend for the focus map
IGraphicsContainer gc = ArcMap.Document.PageLayout as IGraphicsContainer;
IActiveView av = gc as IActiveView;
IMap map = av.FocusMap;
IMapFrame mapFrame = gc.FindFrame(map) as IMapFrame;
ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
uid.Value = "esriCarto.Legend";
IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame((ESRI.ArcGIS.esriSystem.UID)uid, null);

// Size it
IQuerySize querySize = mapSurroundFrame.MapSurround as IQuerySize;
Double w = 0;
Double h = 0;
querySize.QuerySize(ref w, ref h);
Double aspectRatio = w / h;
IEnvelope envelope = new EnvelopeClass();
// The legend is anchored with bottom left corner at x=1, y=2
// Not sure why aspect ratio matters -- just following Esri's example
envelope.PutCoords(1, 2, (1 + 1), (2 + 1 / aspectRatio));
IElement element = mapSurroundFrame as IElement;
element.Geometry = envelope;

// Get the legend object and do something with it
ILegend2 legend = mapSurroundFrame.MapSurround as ILegend2;
// ... some work ... now assume the legend size has changed

// Update size of element containing the legend
querySize.QuerySize(ref w, ref h);
// Convert from points to page units, e.g., inches
w = av.ScreenDisplay.DisplayTransformation.FromPoints(w);
h = av.ScreenDisplay.DisplayTransformation.FromPoints(h);
envelope.PutCoords(1, 2, (1 + w), (2 + h));
element.Geometry = envelope;

// Now add the element to the layout.&amp;nbsp; 
// If you add it earlier, from my experience, sometimes
//&amp;nbsp;&amp;nbsp; the new geometry you assign doesn't stick
gc.AddElement(element, 0);
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:41:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17329#M408</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2021-12-10T20:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17330#M409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your original post wanted to call: FixedAspectRatio&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That method is not implemented in the ILegend, IBoundsProperties or the other Interfaces you have used to create an instance of a legend using IMapSurroundFrame.CreateSurroundFrame and passing the uid of a Legend.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IBoundsProperties does indicate that any class that implements the IBoundsProperties Interface, provide some implementation for the FixedAspectRatio method.&amp;nbsp; So for example, Legend implements the IBoundsProperties Interface, which means that Legend needs to provide the "how" for the FixedAspectRatio method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interfaces are types, just like the CoClasses.&amp;nbsp; What you are doing in your code is declaring a IMapSurroundFrame type and assigning a reference value to that type of yet another Interface type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What you could do is create a MapSurroundFrame variable or an actual Legend variable and assign that to your Interface type reference variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Java, Interfaces as types work like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.oracle.com/javase/tutorial/java/IandI/interfaceAsType.html"&gt;http://docs.oracle.com/javase/tutorial/java/IandI/interfaceAsType.html&lt;/A&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you define a reference variable whose type is an interface, any object you assign to it must be an instance of a class that implements the interface.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see a lot of people on this forum, especially in the .NET user group, assign interface types to other interface variables.&amp;nbsp; I honestly don't know how that works or why more people don't run into problems doing that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 20:15:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17330#M409</guid>
      <dc:creator>LeoDonahue1</dc:creator>
      <dc:date>2014-07-01T20:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17331#M410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your original post wanted to call: FixedAspectRatio&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That method is not implemented in the ILegend, IBoundsProperties or the other Interfaces you have used to create an instance of a legend using IMapSurroundFrame.CreateSurroundFrame and passing the uid of a Legend.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IBoundsProperties does indicate that any class that implements the IBoundsProperties Interface, provide some implementation for the FixedAspectRatio method.&amp;nbsp; So for example, Legend implements the IBoundsProperties Interface, which means that Legend needs to provide the "how" for the FixedAspectRatio method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interfaces are types, just like the CoClasses.&amp;nbsp; What you are doing in your code is declaring a IMapSurroundFrame type and assigning a reference value to that type of yet another Interface type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What you could do is create a MapSurroundFrame variable or an actual Legend variable and assign that to your Interface type reference variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Java, Interfaces as types work like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.oracle.com/javase/tutorial/java/IandI/interfaceAsType.html"&gt;http://docs.oracle.com/javase/tutorial/java/IandI/interfaceAsType.html&lt;/A&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you define a reference variable whose type is an interface, any object you assign to it must be an instance of a class that implements the interface.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see a lot of people on this forum, especially in the .NET user group, assign interface types to other interface variables.&amp;nbsp; I honestly don't know how that works or why more people don't run into problems doing that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 20:28:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17331#M410</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2014-07-01T20:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17332#M411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Your original post wanted to call: FixedAspectRatio&lt;BR /&gt;&lt;BR /&gt;That method is not implemented in the ILegend, IBoundsProperties or the other Interfaces you have used to create an instance of a legend using IMapSurroundFrame.CreateSurroundFrame and passing the uid of a Legend.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, IBoundsProperties does have a FixedAspectRatio property: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/000t/000t000002mz000000.htm"&gt;http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/000t/000t000002mz000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I see a lot of people on this forum, especially in the .NET user group, assign interface types to other interface variables.&amp;nbsp; I honestly don't know how that works or why more people don't run into problems doing that.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is because that of how ESRI has designed ArcObjects and what they consider to be best practices, as shown in all of their examples. I used to think like you though about wanting to get away from interfaces and deal with concrete types. However, if you did get into .Net ArcObjects, you would see how ugly the classes are and that it's a complete waste of time to ever deal with them in any way other than creating a new object and assigning it to an interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If for example, I define a variable of type PolygonClass (Polygon is not the concrete class, PolygonClass is), my variable has, in addition to IsEmpty (from IGeometry), IGeometry2_IsEmpty, IGeometry3_IsEmpty, IGeometry4_IsEmpty, IGeometry5_IsEmpty, IPolygon_IsEmpty, IPolygon2_IsEmpty, IPolygon3_IsEmpty, IPolygon4_IsEmpty, ICurve_IsEmpty, IPolycurve_IsEmpty, and IPolycurve2_IsEmpty. That's 12 different IsEmpty properties! And there are many other examples just like that on this one class alone, not to mention all the other classes! Now in this case, each of those IsEmpty properties would probably all behave exactly the same, but I know there are other cases where properties on different interfaces have the exact same name, but have completely different meanings. If those two interfaces are implemented by a single class, then you really have to be careful about how you call it if your variable is of the class type and not an interface type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm certainly not trying to beat you over the head with the "Program to the interface!" dogma. (I for one only define interfaces in my code when I need to have multiple classes implement some shared functionality that can't be done using a base class.) I also hate the way any time they need to add a new member to an interface, they just create a whole new interface ("IGeometry needs a new XYZ property? Say hello to IGeometry16!" :eek:), which half the time doesn't even inherit from the previous interface! :mad:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I digress... Basically, in the (.net) ArcObjects world, it's just always best to only use interface typed variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for why it works and doesn't break. Sometimes it does break. You always need to check when you are casting types that aren't always compatible (IE: IPolygon and IPolygon4 are always compatible both ways and an IPolygon can always be cast to an IGeometryCollection, but not the other way around) and that you aren't directly in control of.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 01:34:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17332#M411</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2014-07-02T01:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17333#M412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Robby,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I said that IBoundsProperty does not implement FixedAspectRatio, it was not just some uninformed opinion. It is a fact.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/000t/000t000002mw000000.htm"&gt;http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/000t/000t000002mw000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CoClasses "implement" the behavior defined by the Interface.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Interfaces only define a contract, there is nothing between the curly braces, i.e. no implementation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What that is saying is that if you could look at the source code for the IBoundsProperty FixedAspectRatio method, there would be nothing in it.&amp;nbsp; All of those CoClasses that "implement" the interface have to define what FixedAspectRatio means and it could very well be different for different CoClasses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think perhaps we should take the time to educate a little bit on the concept of Interfaces.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/87d83y5b.aspx"&gt;http://msdn.microsoft.com/en-us/library/87d83y5b.aspx&lt;/A&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;An interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is correct to use Interface types as reference variables, but what I was trying to tell the original poster is that you cannot expect to assign Interface types to Interface types and expect to call a method that is only implemented on one of the CoClasses.&amp;nbsp; I was hoping that by reading this he would know how to fix his problem. &lt;/SPAN&gt;&lt;SPAN style="color:#a52a2a;"&gt; He needs to instantiate an instance of whatever CoClass he wants and assign it to an Interface.&amp;nbsp; He was trying to get a Legend by calling some method that returns an Interface and then assign that Interface to his IBoundsProperty Interface and then he didn't know why he couldn't call FixedAspectRatio&lt;/SPAN&gt;&lt;SPAN style="color:#ff8c00;"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I also hate the way any time they need to add a new member to an interface, they just create a whole new interface ("IGeometry needs a new XYZ property? Say hello to IGeometry16!" ), which half the time doesn't even inherit from the previous interface!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;What do you expect to happen here?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you create an Interface called YourInterface and that Interface defines two methods:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;doStuff{}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;doMoreStuff{}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Every CoClass that implements the "YourInterface" Interface will be *required* to implement any additional methods that you add to it, such as doEvenMoreStuff{}.&amp;nbsp; That is how it works in Java.&amp;nbsp; I don't know how .NET handles that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Adding functionality to existing Interfaces breaks all of the CoClass implementations.&amp;nbsp; This is why you see IInterface, IInterface2, IInterface3, etc.&amp;nbsp; Each of those additional Interfaces should be implementing the previous Interface, which is why you only see "additional" methods being defined in those new ones.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know about "half the time".&amp;nbsp; Do you have a specific example of on which Interface that happens?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 13:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17333#M412</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2014-07-02T13:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17334#M413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;CoClasses "implement" the behavior defined by the Interface.&amp;nbsp; &lt;BR /&gt;Interfaces only define a contract, there is nothing between the curly braces, i.e. no implementation.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;:rolleyes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not going to get into some silly academic debate about the word "implement". I am a programmer by trade, not a GIS person, so I understand completely how interfaces work and don't need the idiots guide link to MSDN, Thank you very much. The point was that there was a property on the interface which means that the property must exist on any class that implements the interface. Whether there's anything "between the curly braces" in the source code or not is completely irrelevant because for all we know, they could be auto-properties. (Here's a link to MSDN for you: &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb384054.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb384054.aspx&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It is correct to use Interface types as reference variables, but what I was trying to tell the original poster is that you cannot expect to assign Interface types to Interface types and expect to call a method that is only implemented on one of the CoClasses.&amp;nbsp; I was hoping that by reading this he would know how to fix his problem. &lt;SPAN style="color:#a52a2a;"&gt; He needs to instantiate an instance of whatever CoClass he wants and assign it to an Interface.&amp;nbsp; He was trying to get a Legend by calling some method that returns an Interface and then assign that Interface to his IBoundsProperty Interface and then he didn't know why he couldn't call FixedAspectRatio&lt;/SPAN&gt;&lt;SPAN style="color:#ff8c00;"&gt;.&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, I don't know how much success you had with the OP in that, but that point was clearly lost on me. Why couldn't you have written some sample code to illustrate the proper way of doing it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ironically though, you want to know what the concrete class for ILegend is actually named? LegendClass_2. Because there's an ILegendClass interface with a LegendClass pseudo-class (with its concrete class being LegendClassClass), so they had to append a "_2".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other thing about this is that many times when working with ArcObjects, you don't want to create new objects, you want to get the things that are already on the map. So if the OP's legend is already loaded on the Map, what good is it going to do to call new LegendClass_2()? Also, many classes can not be created and others have no public constructors. In those cases when you need to create a new one of those, you typically have to use a factory of some kind, and the signatures on those factories frequently just specify a return type of object, IObject, or some other useless type that has to be cast to a usable interface type before you can do anything with it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What do you expect to happen here?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;The interface is not designed to be implemented outside of ArcObjects. For example, there's no reason a developer would have production code that would implement the IGeometry interfaces. The only case I can imagine when anyone would ever want to implement those interfaces would be when doing headless unit tests, but that would obviously not be production code.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;The new functionality is going to be added to all of the classes that implement the previous interface.&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;SPAN&gt;If both of those are true, then I expect them to just add the functionality to the existing interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I don't know about "half the time".&amp;nbsp; Do you have a specific example of on which Interface that happens?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sure. ICalculatorUI2 (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/0022/002200000013000000.htm"&gt;http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/0022/002200000013000000.htm&lt;/A&gt;&lt;SPAN&gt;), the reason I joined this forum two weeks ago, which is still a problem for me. It doesn't inherit from ICalculatorUI, even they are only different in one property that was added to ICalculatorUI2. And they are both implemented only by CalculatorUIClass, and there's no reason anyone would have a custom implementation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bottom line to all this, I'm glad the OP was able to figure it out on his own. It clearly wasn't a type casting problem as he would have gotten a NullReferenceException, not a NotImplementedException, though I don't really expect someone who doesn't know C# to know that. But I don't really see how quibbling over whether an interface implements a property or simply defines it is really helping anyone. Any object that can successfully be cast to an interface typed variable MUST have all of the members of that interface implemented, regardless of whether the implementation happened in the object's class or in a base class three levels up. It doesn't matter, so it isn't worth talking about.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW Java programmer, did you not know that in the latest version of Java, interfaces CAN implement methods? (&lt;/SPAN&gt;&lt;A href="http://www.techempower.com/blog/2013/03/26/everything-about-java-8/"&gt;http://www.techempower.com/blog/2013/03/26/everything-about-java-8/&lt;/A&gt;&lt;SPAN&gt;) One of the reasons for this change was to make it easier to add members to interfaces that are already in production. Pretty cool, huh? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 17:01:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17334#M413</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2014-07-02T17:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17335#M414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG&gt;The point was that there was a property on the interface&lt;/STRONG&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;STRONG&gt;which means&amp;nbsp; that the property must exist on any class that implements the interface&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct.&amp;nbsp; Not only must it exist, but the functionality must be provided by the class that implements the Interface, not within the Interface itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your auto-properties example works on classes, not Interfaces.&amp;nbsp; Interfaces are abstract and only define method signatures.&amp;nbsp; You can't instantiate an Interface, so if there was some kind of functionality provided by an auto-property inside an Interface, you would be breaking the nature of an Interface.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG&gt;Why couldn't you have written some sample code to illustrate the proper way of doing it?&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Because the forums shouldn't be vending machines for code samples.&amp;nbsp; Why can't I answer the question the way I want to?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Original Poster did this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ILegend2 legend = mapSurroundFrame.MapSurround as ILegend2; 
IBoundsProperties bounds = legend as IBoundsProperties; 
bounds.FixedAspectRatio = false;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mapSurroundFrame.MapSurround returns an Interface type, not an instance of a CoClass.&amp;nbsp; He is essentially assigning an Interface reference to another Interface reference.&amp;nbsp; Nothing wrong with that at this point, if they were related.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then he assigns the variable bounds (which is an Interface type) a reference type of legend.&amp;nbsp; "legend" is a type of ILegend.&amp;nbsp; Now he has two object references pointing to the same object, whatever it is.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the .NET docs:&amp;nbsp; There is no FixedAspectRatio property on the ILegend Interface:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/000t/000t00000775000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/000t/000t00000775000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know why you want to make it sound like I'm quibbling, it is just a fact.&amp;nbsp; Quibble about it all you want.&amp;nbsp; But at the end, he got a NotImplementedException because he assigned an Interface type (ILegend) which does not implement or even define FixedAspectRatio to a reference variable type of IBoundsProperties which does.&amp;nbsp; The compiler is going to check the actual type of the reference and tell you: "hey, FixedAspectRatio is not implemented on the object type you have currently".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I disagree with you on the IGeometryInterface.&amp;nbsp; Why couldn't it be possible for someone to create their own special geometry class that wants to provide implementation for the methods defined in the IGeometryInterface?&amp;nbsp; Just because you don't do it, doesn't mean someone else might not want to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can define constants in Java Interfaces now and people abuse them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:41:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17335#M414</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2021-12-10T20:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17336#M415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Your auto-properties example works on classes, not Interfaces.&amp;nbsp; Interfaces are abstract and only define method signatures.&amp;nbsp; You can't instantiate an Interface, so if there was some kind of functionality provided by an auto-property inside an Interface, you would be breaking the nature of an Interface.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was merely talking about the "nothing between the curly braces" comment because auto-properties have nothing between the curly braces and look exactly like a property definition on an interface: `public bool FixedAspectRation { get; set; };` That's it. A complete no-code implementation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Because the forums shouldn't be vending machines for code samples.&amp;nbsp; Why can't I answer the question the way I want to?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not saying they should be or that you can't do whatever you want. Just saying that code samples are more helpful than abstract comments about programming. "A code sample is worth 1024 words!" -Me &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;But at the end, he got a NotImplementedException because he assigned an Interface type (ILegend) which does not implement or even define FixedAspectRatio to a reference variable type of IBoundsProperties which does.&amp;nbsp; The compiler is going to check the actual type of the reference and tell you: "hey, FixedAspectRatio is not implemented on the object type you have currently".&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, you're wrong. First off, it wouldn't be the compiler because it's happening at Runtime and because the compiler by definition could never know whether or not two interfaces could be implemented by the same class or not. (Now who's quibbling, right? LOL ;))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other reasons get to the point of why I said I didn't really expect a non-C# programmer to understand it. First of all, the NotImplementedException is never thrown by the CLR. It is in fact a lazy man's implementation. (See this topic on SO: &lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/410719/why-does-notimplementedexception-exist"&gt;http://stackoverflow.com/questions/410719/why-does-notimplementedexception-exist&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, with the code `IBoundsProperties bounds = legend as IBoundsProperties;`, bounds will either be an object of a type that implements IBoundsProperties, or it will be null. If the code was written as `IBoundsProperties bounds = (IBoundsProperties) legend;` then you would get an InvalidCastException if the cast failed. The `as` operator is the conditional cast operator in C# and it will first check to ensure that the cast is valid before doing it and if it isn't valid, then it will return null. That's why I said that that it would have been a NullReferenceException if the object in question did not implement either ILegend2 or IBoundsProperties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will also say though that, even though the casting from IMapSurround to ILegend2 was not a safe cast and should have been tested for null to make sure that the casting worked, the casting from ILegend2 to IBoundsProperties was completely safe since we know from the docs that the only class that implements ILegend2 is LegendClass_2 (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/index.html#/LegendClass_Class/000t00000s06000000/"&gt;http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/index.html#/LegendClass_Class/000t00000s06000000/&lt;/A&gt;&lt;SPAN&gt;) and that class also implements (though poorly, as this case has shown) IBoundsProperties. Therefore, it would not be necessary to test for null after this cast. And even though that could change in a later version, you'll still have to deal with issues when moving to a new version no matter what.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I disagree with you on the IGeometryInterface.&amp;nbsp; Why couldn't it be possible for someone to create their own special geometry class that wants to provide implementation for the methods defined in the IGeometryInterface?&amp;nbsp; Just because you don't do it, doesn't mean someone else might not want to.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, you're free to do whatever you want... But when dealing with real world ArcGIS programming, why would you ever want to? You couldn't assign any of your MySpecialGeometry objects to a feature, nor could they be drawn on the map. So what's the point?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can define constants in Java Interfaces now and people abuse them.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do that too, but I was talking about the default method implementations where you can write out the code for methods that are defined in the interface. Thus your class wouldn't have to provide an implementation for that method when it implements the interface. Would you consider that to be "breaking the nature of an interface" as you stated auto-properties in an interface would be? I know it's a hotly debated issue in some circles, but I personally think it's a pretty cool idea that gets rid of a lot of boilerplate code and annoying tedium in Java. Next they just need to add true properties instead of having getters and setters everywhere. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 19:37:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17336#M415</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2014-07-02T19:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17337#M416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Robby, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Every once in a while I get into conversations like these.&amp;nbsp; It usually starts and ends the same way every time where someone wants to get in a word battle with me over what did you call it - academic meanings?&amp;nbsp; I'm just using the standard language that is out there and I always run into people who what to use a different language (not programming language) in which to communicate.&amp;nbsp; If you have a better word for my use of the word "implement" for classes that need to provide the guts to the method signatures in Interfaces, let me hear it.&amp;nbsp; I'd be glad to consider to start using it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll agree to comment on the last paragraph where you asked my opinion about the Java 8 feature of default methods in Interfaces.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think if people "want" to add default methods to Interfaces, then maybe they should be looking at extending an Abstract Class for that instead.&amp;nbsp; Abstract Classes can have "implementation" code in their methods.&amp;nbsp; And, since you can re-declare and re-define the default methods in Interfaces, what would be the point?&amp;nbsp; You would be breaking the intent of having a default method in Interfaces in the first place.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But... with default non-abstract methods in Interfaces I can see where you gain the ability to have Abstract Class behavior without needing to declare "your" class as Abstract.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would be interested to know what "use cases" there are that have been championing this change in Java 8.&amp;nbsp; I know, Lambda expressions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And to be fair, this new feature is a way to provide other new features without breaking the Collections API.&amp;nbsp; So I don't know what to think about it, really.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 02:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17337#M416</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2014-07-03T02:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17338#M417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Every once in a while I get into conversations like these.&amp;nbsp; It usually starts and ends the same way every time where someone wants to get in a word battle with me over what did you call it - academic meanings?&amp;nbsp; I'm just using the standard language that is out there and I always run into people who what to use a different language (not programming language) in which to communicate.&amp;nbsp; If you have a better word for my use of the word "implement" for classes that need to provide the guts to the method signatures in Interfaces, let me hear it.&amp;nbsp; I'd be glad to consider to start using it.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I must admit that I'm not sure what exactly this is in response to in my last message. It would fit much better as a response to previous messages, though as I recall, I made a similar statement about having a "silly academic debate about the meaning of the word 'implement'". I don't really think that's what's happening though as I've already conclusively proven that the cast to IBoundsProperties was successful and thus both the ILegend2 and IBoundsProperties interfaces (and thus all of their members) were in fact implemented by the OP's object. So I think we are in agreement over the meaning of the word in this context.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only possible point where we could disagree about this at this point would be if you argued that a class that implements a property by causing it to throw a NotImplementedException (which is what Visual Studio does when it stubs them out) is not actually implementing the property or interface. While true that it is not a useful implementation and should never happen in production code, it isn't true from the perspective of the programming language itself. Nor is it something that can ever be tested for, like you can test whether or not an object implements an interface. It could only be discovered by attempting to use that property and catching the exception. Documentation could also help, but I haven't found anything in the docs that mention anything about this property being unsupported for legends like what I found for ILabelEngineLayerProperties in another thread (&lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/114312-how-to-obtain-ILabelEngineLayerProperties2-and-error-calling-it-s-method"&gt;http://forums.arcgis.com/threads/114312-how-to-obtain-ILabelEngineLayerProperties2-and-error-calling-it-s-method&lt;/A&gt;&lt;SPAN&gt;) - which should have been handled with a NotSupportedException, not a NotImplementedException.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, I tried to reproduce the issue that the OP was having, but I couldn't get it to throw an exception. I also couldn't get it to work either though, FixedAspectRatio remained true even after setting it to false. I am running on 10.1 though, so perhaps they changed the implementation between 10.0 and 10.1. *shrugs*&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I think if people "want" to add default methods to Interfaces, then maybe they should be looking at extending an Abstract Class for that instead.&amp;nbsp; Abstract Classes can have "implementation" code in their methods.&amp;nbsp; And, since you can re-declare and re-define the default methods in Interfaces, what would be the point?&amp;nbsp; You would be breaking the intent of having a default method in Interfaces in the first place.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing about abstract classes though is that sometimes you don't have the option of choosing what you inherit from. For example, if I wanted to add a function BlinkingText to certain controls, like TextBoxes and Labels which would cause their text to blink for 3 seconds and then I also wanted it to work on my Form so that the title of the form would blink, there's no where in the inheritance hierarchy that I could put an abstract class that all three of those could inherit from. If however I could define an interface that says that it has a Text property (which all three classes have already) and then defines my function with a default implementation that causes the Text to blink for 3 seconds, then all I would have to do is add that interface to my classes that inherit from those three classes and everything works. Now, I can already achieve this simple functionality in C# using extension methods, but this was just a simple example to illustrate the inheritance hierarchy problem, which can't always be handled as easily.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regardless, I've enjoyed our discussion (despite a couple rocky points) and I hope you have too. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 13:27:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17338#M417</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2014-07-03T13:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17339#M418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Leo, my man. I was just trying to help out tomalley23 on his question and found out he's using Java ArcObjects. That led me to go to the docs and now I understand why you were so insistent to begin with that the OP create a new object! LOL&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apparently you can't get an actual Workspace from an IWorkspaceFactory and you have to do something like this example from the docs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
IWorkspaceFactory rasWkspFactory = new RasterWorkspaceFactory();
IWorkspace wksp = new RasterWorkspace(rasWkspFactory.openFromFile(aPath, 0));
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is so unbelievable! LMAO&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seriously glad I don't have to do stupid stuff like that. You deserve some serious props, man. I thought to begin with that it was just a philosophical dislike for working with interfaces all the time in ArcObjects and you just hadn't gotten into the whole mentality of how ArcObjects is designed. But now I see that the Java ArcObjects is this crazy stupid thing where you'll get an exception if you just use `IWorkspace wksp = rasWskpFactory.openFromFile(aPath, 0);` even though the docs say that openFromFile returns an IWorkspace! WTF! It seriously blows my mind! LMAO&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My coworkers must think I'm losing my mind right now cause I've been laughing so hard.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyways. Would you mind taking a look at tomalley23's question? I know I can't help him out with that at this point. And I'm going to make sure to state on my resume next time I'm looking for a job that even though I know Java and I know ArcObjects, I do NOT know Java ArcObjects! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good times, buddy. :cool:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:41:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17339#M418</guid>
      <dc:creator>RobertMaddox</dc:creator>
      <dc:date>2021-12-10T20:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17340#M419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;gt;Would you mind taking a look at tomalley23's question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me find it in this new forum?&amp;nbsp; I don't remember the title of that post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 00:06:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17340#M419</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2014-07-09T00:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to set FixedAspectRatio to False for Legend</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17341#M420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just tested in 10.1 and had the same result as Robert: No exception was thrown, but FixedAspectRatio remained true even after setting it to false.&amp;nbsp; However, I also found that the legend was able to adjust its width and height properties correctly without my intervention, so my solution of programmatically updating the size of the element containing the legend is no longer necessary in ArcGIS 10.1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 19:17:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-fixedaspectratio-to-false-for-legend/m-p/17341#M420</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2014-07-24T19:17:33Z</dc:date>
    </item>
  </channel>
</rss>

