WPF c# onStartUp() view model problem with multiple data inputs
-
Hey all I have the following OnStartup for my WPF desktop app that goes to a local directory and gathers all the images within that folder (box1 being the example code below):
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);// set the update interval var imageSource = new ImageSource(Path.Combine(@"C:\\photos\\boxes\\", "box1"), TimeSpan.FromHours(1)); var viewModel = new MainWindowViewModel(imageSource); var window = new MainWindow() { DataContext = viewModel }; window.Closed += (s, a) => { viewModel.Dispose(); }; window.Show(); } }
This works just fine for the component I have on the MainWindow.xaml that's label box1 but the other boxes 2-9 do not load their own images from their respective folders - they all show the same images as box1 has.
The structure of the directory is this:
C:\\ |-photos\\ |boxes\\ |box1 |box2 |box3 |box4 |box5 |box6 |box7 |box8 |box9 |box10
On the MainWindow I have this code that allows all those photos from each directory into its own element:
-
Hey all I have the following OnStartup for my WPF desktop app that goes to a local directory and gathers all the images within that folder (box1 being the example code below):
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);// set the update interval var imageSource = new ImageSource(Path.Combine(@"C:\\photos\\boxes\\", "box1"), TimeSpan.FromHours(1)); var viewModel = new MainWindowViewModel(imageSource); var window = new MainWindow() { DataContext = viewModel }; window.Closed += (s, a) => { viewModel.Dispose(); }; window.Show(); } }
This works just fine for the component I have on the MainWindow.xaml that's label box1 but the other boxes 2-9 do not load their own images from their respective folders - they all show the same images as box1 has.
The structure of the directory is this:
C:\\ |-photos\\ |boxes\\ |box1 |box2 |box3 |box4 |box5 |box6 |box7 |box8 |box9 |box10
On the MainWindow I have this code that allows all those photos from each directory into its own element:
You don't appear to be varying your input path. You need a list or a "box path counter".
var imageSource = new ImageSource(Path.Combine(@"C:\photos\boxes\", "box1"),
TimeSpan.FromHours(1));"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
Hey all I have the following OnStartup for my WPF desktop app that goes to a local directory and gathers all the images within that folder (box1 being the example code below):
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);// set the update interval var imageSource = new ImageSource(Path.Combine(@"C:\\photos\\boxes\\", "box1"), TimeSpan.FromHours(1)); var viewModel = new MainWindowViewModel(imageSource); var window = new MainWindow() { DataContext = viewModel }; window.Closed += (s, a) => { viewModel.Dispose(); }; window.Show(); } }
This works just fine for the component I have on the MainWindow.xaml that's label box1 but the other boxes 2-9 do not load their own images from their respective folders - they all show the same images as box1 has.
The structure of the directory is this:
C:\\ |-photos\\ |boxes\\ |box1 |box2 |box3 |box4 |box5 |box6 |box7 |box8 |box9 |box10
On the MainWindow I have this code that allows all those photos from each directory into its own element:
No related to your question but.... you XAML format is absurd. That's not at all standard and will cause TAB issues.
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.