У меня есть этот код здесь из MainWindow.xaml.cs в приложении WPF
public partial class MainWindow : Window
{
animaciones.Preferences Preferences;
animaciones.GameOver GameOver;
ObservableCollection<Figura> listafiguras = new ObservableCollection<Figura>();
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
DispatcherTimer timer;
Raton raton;
public MainWindow()
{
InitializeComponent();
Preferences = new animaciones.Preferences();
GameOver = new animaciones.GameOver();
raton = new Raton();
player.SoundLocation = "lostwoods.wav";
Canvas.SetLeft(raton.fig, raton.x);
Canvas.SetBottom(raton.fig, raton.y);
lienzo.Children.Add(raton.fig);
this.KeyDown += new KeyEventHandler(KeyDownEventos);
timer = new DispatcherTimer();
timer.Tick += OnTick;
timer.Interval = new TimeSpan(0, 0, 0, 0, 50);
}
Я хочу использовать ObservableCollection "listafiguras" в другом xaml.cs, например:
public partial class Preferences : Window
{
public Preferences()
{
InitializeComponent();
tabla.ItemsSource = MainWindow.listafiguras;
}
Но в нем говорится, что MainWindow недоступен из-за уровня защиты. Как я могу изменить это, чтобы дать доступ к моей переменной? Спасибо