Something like:
<DesignTimeHidden()开发者_如何学编程> _
Private Sub UserControl_IsVisibleChanged(sender As Object, _
e As DependencyPropertyChangedEventArgs) Handles Me.IsVisibleChanged
End Sub
It sounds like you want a method which, if called at design-time, is ignored, but can still be called at run-time.
This is not possible with an attribute. However your method code can check if it is being called at design time and return without doing anything. How you do this depends on your environment.
For components such as WinForms or ASP.NET controls, check the
DesignMode
property (note this is not set until after construction, so is not reliable in the constructor or methods called from the constructor).For WPF components, call
DesignerProperties.IsInDesignMode(this)
.
精彩评论