알아 냈습니다. 여기에 나와있는 예제가 정확히 설명하는 C# 예제가 있습니다. 희망이 사람을 도움이됩니다.
public class MyControl : Control
{
private Font myOtherFont;
public Font MyOtherFont
{
get
{
if (this.myOtherFont == null)
{
if (base.Parent != null)
return base.Parent.Font;
}
return this.myOtherFont;
}
set
{
this.myOtherFont = value;
}
}
private bool ShouldSerializeMyOtherFont()
{
if (base.Parent != null)
if (base.Parent.Font.Equals(this.MyOtherFont))
return false;
if (this.MyOtherFont == null)
return false;
return true;
}
private void ResetMyOtherFont()
{
if (base.Parent != null)
this.MyOtherFont = base.Parent.Font;
else
this.MyOtherFont = Control.DefaultFont;
}
}
충분하지 않습니다. 속성을 다시 설정하여 주변 환경이되도록 다시 설정해야합니다. ResetMyOtherFont() 메소드. 디자이너에게 [AmbientValue] 속성에 대해 알려줍니다. –
@HansPassant 거기에 ResetMyOtherFont 메서드가 있습니다. 그 속성이 어떻게 그 속성에 사용되어야하는지 잘 모르겠다. 어떤 통찰력? – test
처음으로 상위 글꼴을 가져올 때 상속 된 글꼴을 기본 글꼴로 설정하여 액세스 할 때마다 확인할 두 개의 if 문이 없도록 할 수 있습니다 – Sayse