namespace Petzold.CompileXamlWindow
{
public partial class CompileXamlWindow : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new CompileXamlWindow());
}
public CompileXamlWindow()
{
// Required method call to hook up event handlers and
// initialize fields.
InitializeComponent();
// Fill up the ListBox with brush names.
foreach (PropertyInfo prop in typeof(Brushes).GetProperties())
lstbox.Items.Add(prop.Name);
}
// ListBox event handler changes Fill property of Ellipse.
void ListBoxOnSelection(object sender, SelectionChangedEventArgs args)
{
ListBox lstbox = sender as ListBox;
string strItem = lstbox.SelectedItem as string;
PropertyInfo prop = typeof(Brushes).GetProperty(strItem);
elips.Fill = (Brush)prop.GetValue(null, null);
}
}
}
이거 보면 생성자에서 lstbox 변수 접근해서 반복문 돌리잖아?
근데 멤버변수도 아니고 메서드 내에 지역변수인데
어떻게 접근하는거임?
댓글 0