locked
Disabling specific properties (Megha) - 3/12/2007 1:26 AM PST RRS feed

  • Question

  • By: Megha

    How do I disable selected properties for my custom control at design time? I 
    also have a customized property for my control. I am able to pop up a window 
    when the button ("NEW") next to this property is clicked. But how do I 
    disable the default properties of this button, like AllowDrop, Background etc?
    Tuesday, February 19, 2008 9:12 PM

Answers

All replies

  • By: Brennon Williams
    Howdy,

    When you inherit from a control, for exanple a Button, you can use the
    override method to remove functionality...

    So for example, in a button, if you want to remove the functionality of the
    click method, you can do the following:

    class MyClass : Button
    {

    protected override void OnClick()
    {

    }
    }

    which will disable the event raised on the clcik.

    Is this what you meant?

    Cheers
    --
    http://www.learnexpressionblend.com
    http://www.expressionblend.com
    http://www.resourcedictionary.com
    http://www.x-coders.com


    "Megha" wrote:

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 11:51 PM
  • By: Unni Ravindranathan (MS)
    I think Megha was talking about using our metadata system to disable
    properties. If you just want to hide a property and prevent it from showing
    in the property grid, one way would be to use the EditorBrowsable attribute
    that you can tag onto the property - something like:

    using System.ComponentModel;

    public class Foo
    {
    private string bar;
    [EditorBrowsable(EditorBrowsableState.Never)]
    public string Bar
    {
    get { return bar; }
    set { bar = value; }
    }
    }

    Thanks,
    -Unni

    "Brennon Williams" <BrennonWilliams@discussions.microsoft.com> wrote in
    message news:CE0C2FCA-CF38-4491-BA40-28BB0A0F0012@microsoft.com...

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 11:52 PM
  • By: Megha

    Hi,
    Thanks for the help. Have another question. For a custom button, I have
    written my own property, with its popup window. There's a button on this
    window. When this button is clicked I want to change the height of the custom
    button, ie i want this change to be reflected in the xaml. is this possible?

    Megha

    "Unni Ravindranathan (MS)" wrote:

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 11:53 PM
  • By: Unni Ravindranathan (MS)
    No, you cannot do this in v1. Our property grid extensibility APIs are only
    designed to work with a property - you don't have access to the entire scene
    graph so you can do arbitrary manipulations.

    This is a feature we are seriously investigating for a future release.

    thanks,
    -Unni

    "Megha" <Megha@discussions.microsoft.com> wrote in message
    news:1A23FF31-54D8-4995-A575-96D3C5E409A8@microsoft.com...
    > Hi,
    > Thanks for the help. Have another question. For a custom button, I have
    > written my own property, with its popup window. There's a button on this
    > window. When this button is clicked I want to change the height of the
    > custom
    > button, ie i want this change to be reflected in the xaml. is this
    > possible?
    >
    > Megha
    >
    > "Unni Ravindranathan (MS)" wrote:
    >
    >> I think Megha was talking about using our metadata system to disable
    >> properties. If you just want to hide a property and prevent it from
    >> showing
    >> in the property grid, one way would be to use the EditorBrowsable
    >> attribute
    >> that you can tag onto the property - something like:
    >>
    >> using System.ComponentModel;
    >>
    >> public class Foo
    >> {
    >> private string bar;
    >> [EditorBrowsable(EditorBrowsableState.Never)]
    >> public string Bar
    >> {
    >> get { return bar; }
    >> set { bar = value; }
    >> }
    >> }
    >>
    >> Thanks,
    >> -Unni
    >>
    >> "Brennon Williams" <BrennonWilliams@discussions.microsoft.com> wrote in
    >> message news:CE0C2FCA-CF38-4491-BA40-28BB0A0F0012@microsoft.com...
    >> > Howdy,
    >> >
    >> > When you inherit from a control, for exanple a Button, you can use the
    >> > override method to remove functionality...
    >> >
    >> > So for example, in a button, if you want to remove the functionality of
    >> > the
    >> > click method, you can do the following:
    >> >
    >> > class MyClass : Button
    >> > {
    >> >
    >> > protected override void OnClick()
    >> > {
    >> >
    >> > }
    >> > }
    >> >
    >> > which will disable the event raised on the clcik.
    >> >
    >> > Is this what you meant?
    >> >
    >> > Cheers
    >> > --
    >> >
    http://www.learnexpressionblend.com
    >> >
    http://www.expressionblend.com
    >> >
    http://www.resourcedictionary.com
    >> >
    http://www.x-coders.com
    >> >
    >> >
    >> > "Megha" wrote:
    >> >
    >> >> How do I disable selected properties for my custom control at design
    >> >> time? I
    >> >> also have a customized property for my control. I am able to pop up a
    >> >> window
    >> >> when the button ("NEW") next to this property is clicked. But how do I
    >> >> disable the default properties of this button, like AllowDrop,
    >> >> Background
    >> >> etc?
    >>
    >>
    >>


    Tuesday, February 19, 2008 11:53 PM