NotifyParentPropertyAttribute(Boolean) Constructor
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de NotifyParentPropertyAttribute klasse met behulp van de opgegeven waarde om te bepalen of de bovenliggende eigenschap op de hoogte wordt gesteld van wijzigingen in de waarde van de eigenschap.
public:
NotifyParentPropertyAttribute(bool notifyParent);
public NotifyParentPropertyAttribute(bool notifyParent);
new System.ComponentModel.NotifyParentPropertyAttribute : bool -> System.ComponentModel.NotifyParentPropertyAttribute
Public Sub New (notifyParent As Boolean)
Parameters
- notifyParent
- Boolean
true indien het bovenliggende element op de hoogte moet worden gesteld van wijzigingen; anders, false.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de NotifyParentPropertyAttribute en de ExpandableObjectConverter klasse gebruikt om een uitbreidbare eigenschap te maken voor een aangepast besturingselement.
[TypeConverter(typeof(BorderAppearanceConverter))]
public class BorderAppearance
{
int borderSizeValue = 1;
Color borderColorValue = Color.Empty;
[Browsable(true),
NotifyParentProperty(true),
EditorBrowsable(EditorBrowsableState.Always),
DefaultValue(1)]
public int BorderSize
{
get => borderSizeValue;
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException(
"BorderSize",
value,
"must be >= 0");
}
if (borderSizeValue != value)
{
borderSizeValue = value;
}
}
}
[Browsable(true)]
[NotifyParentProperty(true)]
[EditorBrowsable(EditorBrowsableState.Always)]
[DefaultValue(typeof(Color), "")]
public Color BorderColor
{
get => borderColorValue;
set
{
if (value.Equals(Color.Transparent))
{
throw new NotSupportedException("Transparent colors are not supported.");
}
if (borderColorValue != value)
{
borderColorValue = value;
}
}
}
}
<TypeConverter(GetType(BorderAppearanceConverter))> _
Public Class BorderAppearance
Private borderSizeValue As Integer = 1
Private borderColorValue As Color = Color.Empty
<Browsable(True), NotifyParentProperty(True), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(1)> _
Public Property BorderSize() As Integer
Get
Return borderSizeValue
End Get
Set
If value < 0 Then
Throw New ArgumentOutOfRangeException("BorderSize", value, "must be >= 0")
End If
If borderSizeValue <> value Then
borderSizeValue = value
End If
End Set
End Property
<Browsable(True), NotifyParentProperty(True), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(GetType(Color), "")> _
Public Property BorderColor() As Color
Get
Return borderColorValue
End Get
Set
If value.Equals(Color.Transparent) Then
Throw New NotSupportedException("Transparent colors are not supported.")
End If
If borderColorValue <> value Then
borderColorValue = value
End If
End Set
End Property
End Class