我希望能在WPF的用户控件中调用一个方法。我有一个带列表的窗口,并且我有一个获取此列表的方法。
我希望在用户控件内做类似这样的事情:
private ObservableCollection<int> _lst;
public MainWindow()
{
InitializeComponent();
getList();
}
public void getList()
{
_lst = List<int>();
}
在这个页面中,我使用了一个用户控件:
UserControlAAA userControl = new UserControlAAA ();
gridDatos.Children.Add(userControl);
我希望在用户控件内做类似这样的事情:
Window win = Window.GetWindow(this);
win.getList();
但是我无法调用win.getList();
我想从我的用户控件中调用getList方法,但我不知道如何做到这一点。