locked
custom value editor RRS feed

  • Question

  • In VS2012 RC1, I want to write a custom editor by setting ValueEditor in the XAML file and creating a class derived from IPropertyPageUIValueEditor with a function EditValue in the C# code. However when I set a breakpoint there, it is never reached. What am I missing?

    Thursday, June 21, 2012 3:16 PM

All replies

  • This post is the only hit on Google/Bing for IPropertyPageUIValueEditor, so I have no idea what that is. You would need to give more context here.  What is a 'custom value editor'?  Is this for the XAML designer?

    Ryan

    Thursday, June 21, 2012 5:38 PM
  • Hello Ryan,

    this is for custom properties added as a category for C/C++ project in Visual Studio 2012. Adding the properties works, but I want to use a non standard editor to edit one of the properties. So far I have not succeeded in getting the editor code executed. If anyone has a sample (including XAML and CS), that may help.

    Regards, Jan


    Jan

    Thursday, June 21, 2012 6:25 PM
  • Where are you finding information on this IPropertyPageUIValueEditor or instructions on its usage?  I have never heard of it so I can't really offer any advice on how to 'get it working'.

    Ryan

    Thursday, June 21, 2012 9:18 PM
  • Let me step back then: what I want is for my Visual Studio project property to have a custom value editor. There is a file MyProperties.xaml containing an IntProperty with a ValueEditor clause:
    <IntPropertyName="MyProp"DisplayName="My Property"Description="This is my property.">
    <IntProperty.ValueEditors>
     
    <ValueEditorDisplayName="My editor"EditorType="MyEditor" />
    </IntProperty.ValueEditors>
    </IntProperty>

    Now I need to code the C# function that actually deals with that. It should be something like this, but there is no sample or whatsoever on how to do this:
    [Export(typeof(IPropertyPageUIValueEditor))]
    [
    ExportMetadata("Name", "MyEditor")]
    // [ProjectScope(ProjectScopeRequired.None)] -- this did not compile
    publicclassMyEditor: IPropertyPageUIValueEditor
    {
    publicboolEditValue(IServiceProviderserviceProvider, IPropertyruleProperty, objectcurrentValue, outobjectnewValue)
    {

    but this code is never executed. Any suggestions?Regards, Jan


    Jan

    Friday, June 22, 2012 8:58 AM
  • You would need to explain where you saw documentation saying that that code would ever be executed. I see nothing about the interface you are exporting, why do you believe Visual Studio knows anything about it or uses it in any way?

    Ryan

    Saturday, June 23, 2012 7:26 PM
  • Hello Ryan,

    Let me step back again: what I want is for my Visual Studio project property to have a custom value editor. I would like to see code of a working sample. There has to be some, right? My code was suggested by engineers from Visual Studio at a VSIP meeting, but I cannot get it to work.

    Regards, Jan


    Jan

    Monday, June 25, 2012 6:50 AM
  • >There has to be some, right?

    Not necessarily, VS has a LARGE extensibility surface, there aren't samples of every possible thing.

    >My code was suggested by engineers from Visual Studio at a VSIP meeting

    Who specifically? That would probably be the easiest way for me to point them to this post. I know nothing about project properties and custom editors, though since each project system provides its own project properties implementation (to my knowledge) I would imagine there isn't a generic way to make it work for any project system, so I would probably want to talk to someone on say the C++ team as to how you are supposed to do this for the C++ project system

    Ryan

    Monday, June 25, 2012 3:49 PM
  • I was the VSIP guy who suggested this extensibility point would help Jan. 

    Jan, your XAML and C# code so far looks good (ProjectScope is removed in Dev11, so you can remove that attribute).  You say your code doesn't ever execute -- but what are you doing in the IDE that you expect should trigger your code?  

    Custom value editors are invoked when the user is in the property page, looking at your property, clicks the down arrow to the right of the property value and then selects your value editor.  When you do this, what happens?

    Monday, June 25, 2012 5:58 PM
  • Hello Andrew,

    nice to meet you on this road!

    When I open the properties, select my category, there is a down button on th evalue,  but it only mentions <inherit..>. I tried editing the value directly but that does not call the C# function. What is missing?

    Regards, Jan


    Jan

    Monday, June 25, 2012 6:53 PM
  • OK, so the first sign of trouble is that the dropdown list doesn't include "My editor".  I wonder if VS hasn't recognized your assembly as a MEF container.

    Are you installing your extension assembly (that contains the [Export]) via VSIX?  And do you have an extension.vsixmanifest file that lists your DLL as a MEF assembly?  (can you include your .vsixmanifest file)?

    Tuesday, June 26, 2012 3:32 PM
  • Hello Andrew,

    here is the vsixmanifest file:

    <?xml version="1.0" encoding="utf-8"?>
    <Vsix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
      <Identifier Id="INtimeDebugger.Microsoft IT.bd12ed5f-9fd8-4752-966a-54f698cc150a">
        <Name>INtimeDebugger</Name>
        <Author>TenAsys Corporation</Author>
        <Version>1.0</Version>
        <Description xml:space="preserve">This is part of the solution to get INtime projects in Visual Studio to use the INtime debugger</Description>
        <Locale>1033</Locale>
        <MoreInfoUrl>http://www.tensays.com</MoreInfoUrl>
        <SupportedProducts>
          <VisualStudio Version="11.0">
            <Edition>Pro</Edition>
            <Edition>Premium</Edition>
            <Edition>Ultimate</Edition>
          </VisualStudio>
        </SupportedProducts>
        <SupportedFrameworkRuntimeEdition MinVersion="4.5" MaxVersion="4.5" />
      </Identifier>
      <References />
      <Content>
        <MefComponent>|%CurrentProject%|</MefComponent>
      </Content>
    </Vsix>

    and this is the relevant part of the C# implementation:

    namespace INtimeDebugger
    {
        [Export(typeof(IPropertyPageUIValueEditor))]
        [ExportMetadata("Name", "INtimeMinPoolConverter")]
        public class INtimeMinPoolConverter : IPropertyPageUIValueEditor
        {
            public bool EditValue(IServiceProvider serviceProvider, IProperty ruleProperty, object currentValue, out object newValue)
            {
                string valueAsString = currentValue as string;
                if (valueAsString != null)
                {
                    int valueAsNumber;
                    if (int.TryParse(valueAsString, out valueAsNumber))
                    {
                        newValue = valueAsNumber * 1024 * 1024;
                        return true;
                    }
                }

                newValue = null;
                return false;
            }
        }
    }

    Regards, Jan


    Jan

    Tuesday, June 26, 2012 5:31 PM
  • Hi,

    I can't search the interface of IPropertyPageUIValueEditor, is it be defined by yourself? Where are you import it?

    Thursday, June 28, 2012 8:35 AM
  • Hello Disley,

    forget the IPropertyPageUIValueEditor, it may be a red herring.

    Regards, Jan


    Jan

    Friday, June 29, 2012 9:56 AM
  • Hi Jan,

    How is your project going on? Can your codes execute now?

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 2, 2012 8:52 AM
  • Hello Ego,

    we are making progress. One of your colleagues is helping me.

    Regards, Jan


    Jan

    Monday, July 2, 2012 9:08 AM
  • Hi Jan,

    I'm glad to hear one of my colleagues is helping you.

    I will care your issue till your issue has been solved. If you have any new questions about this issue, please feel free to let us know.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, July 3, 2012 9:19 AM