Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C# WPF MVVM viewmodel App.xaml OnStartup calling more than one call

stealthrt

New Coder
Hey all I am terrible at MVVM so I hope someone more knowledgeable will be able to answer my question.

I have a app that, when started, first calls the view model (App.xaml) and calls a function that passes images from a folder(s). The issue being that I am unsure how to call more than just that one call:

C#:
protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);

    string boxPath = Environment.CurrentDirectory + @"\boxes";
    // set the update interval
    var imageSource = new ImageSource(Path.Combine(boxPath, "box1"), TimeSpan.FromHours(1));
    var viewModel = new MainWindowViewModel(imageSource);
    var window = new MainWindow()
    {
        DataContext = viewModel
    };

    window.Closed += (s, a) => { viewModel.Dispose(); };
    window.Show();
}

The code ImageSource(Path.Combine(boxPath, "box1"), TimeSpan.FromHours(1)); is what I am in need of modifying so that I can include calls for all my boxes (1-10) instead of just that one.

How would I modify this in order to call more than one box1? I'd really rather call the boxes from a viewmodel instead of inside the app.xaml but I am not sure if that's possible or not?
 
Back
Top Bottom