Click here to Skip to main content
15,881,380 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin22-Feb-18 5:29
Leif Simon Goodwin22-Feb-18 5:29 
GeneralRe: WPF memory leak BitmapImage Pin
Gerry Schmitz22-Feb-18 5:54
mveGerry Schmitz22-Feb-18 5:54 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin22-Feb-18 23:57
Leif Simon Goodwin22-Feb-18 23:57 
AnswerRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin8-Mar-18 22:35
Leif Simon Goodwin8-Mar-18 22:35 
Question"Cylinder lens" scrollbar Pin
kalberts19-Feb-18 3:33
kalberts19-Feb-18 3:33 
AnswerRe: "Cylinder lens" scrollbar Pin
Gerry Schmitz19-Feb-18 6:53
mveGerry Schmitz19-Feb-18 6:53 
GeneralRe: "Cylinder lens" scrollbar Pin
kalberts19-Feb-18 22:18
kalberts19-Feb-18 22:18 
QuestionPassing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Dwayne Barsotta27-Jan-18 6:05
Dwayne Barsotta27-Jan-18 6:05 
I have been up almost all night reading on this subject. I have my main ViewModel (ShellViewModel), when the user selects a button a new window opens for the user to type something and a file chooser to select the file to read.

All I want to do is pass the Text typed in and the file path (as a string) back to the main view model for processing.

I believe I understand the concept of using EventAggregator to pass an event containing the data I want from the second window to the first. My problem is all the examples are showing the main VM creating two separate VM and the data is passed between the two individual VM's.

My ShellViewModel has the following method when the button is selected (I know using WindowManager in this fashion is not "best practice", but works for now:

public void LoadSchedule()
        {
            WindowManager windowManager = new WindowManager();
            SelSchedViewModel vm = new SelSchedViewModel();
            windowManager.ShowDialog(vm);
        }

I have added a Handle to the ShellViewModel as well as Implimented "IHandle<scheduleinfo>"

Handle Code in ShellViewModel:
public void Handle(ScheduleInfo message)
        {
            ScheduleName = message.ScheduleName;
            FileInfo = message.FileLocation;
        }


I have created the class "SheduleInfo" to hold the data for the event

public class ScheduleInfo
    {
        public string ScheduleName
        {
            get;
            private set;
        }

        public string FileLocation
        {
            get;
            private set;
        }

        public ScheduleInfo(string SN, string FL)
        {
            ScheduleName = SN;
            FileLocation = FL;
        }
    }


SheduleName and FileLocation have been added to ShellViewModel:
public string ScheduleName
        {
            get { return _scheduleName; }
            set {
                _scheduleName = value;
                NotifyOfPropertyChange(() => ScheduleName);
            }
        }
        public string FileInfo
        {
            get { return _fileInfo; }
            set {
                _fileInfo = value;
                NotifyOfPropertyChange(() => FileInfo);
            }
        }


The second window "SelSchedViewModel" has a load button that when text is written in the text box and a file has been selected, is supposed to pass that data back and close this windows.

I am stuck on how to set up the SelShedViewModel to send the data back and how to properly initialize EventAggregator in the ShellViewModel and in the second view model. All the tutorials I found use the constructor of the receiving View Model (I tried) adding below to my ShellViewModel but I cant access "events"
public ShellViewModel()
        {
            IEventAggregator events = new EventAggregator();
        }


I was thinking I need to move below to the ShellViewModel constructor and just use Windows Manager to call it, adding the "events" (will try this in a bit):

SelSchedViewModel vm = new SelSchedViewModel(events);


I don't know why this concept is confusing me so much. I have made the entire project public on gitHub for now. Any help would be appreciated.

And if y'all (yes I live in Texas) want to supply constructive criticism on my project be my guess. Remember the project was private until no so the commit messages were intended for me and might be a little rough Sniff | :^)

[Link to my project on GitHub]

BTW, I am self-learning so I am looking for help to get this done not for anyone to do it for me. This project is a tool I want to use to make one of my normal day to day operations quicker at work, this is not a "for sale" project.

Thank You all for the help! Sorry for the length (here's a potatoe[some might get this old comment] - stress enduced humor)
AnswerRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Gerry Schmitz27-Jan-18 12:10
mveGerry Schmitz27-Jan-18 12:10 
GeneralRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Dwayne Barsotta27-Jan-18 12:20
Dwayne Barsotta27-Jan-18 12:20 
GeneralRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Gerry Schmitz27-Jan-18 12:54
mveGerry Schmitz27-Jan-18 12:54 
GeneralRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Dwayne Barsotta27-Jan-18 19:47
Dwayne Barsotta27-Jan-18 19:47 
GeneralRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Gerry Schmitz28-Jan-18 8:28
mveGerry Schmitz28-Jan-18 8:28 
QuestionWPF ListCollectionView CustomSort - how to turn off live sorting Pin
Jonas Thor27-Jan-18 1:16
Jonas Thor27-Jan-18 1:16 
AnswerRe: WPF ListCollectionView CustomSort - how to turn off live sorting Pin
Gerry Schmitz27-Jan-18 12:19
mveGerry Schmitz27-Jan-18 12:19 
GeneralRe: WPF ListCollectionView CustomSort - how to turn off live sorting Pin
Jonas Thor31-Jan-18 4:00
Jonas Thor31-Jan-18 4:00 
GeneralRe: WPF ListCollectionView CustomSort - how to turn off live sorting Pin
Gerry Schmitz31-Jan-18 6:03
mveGerry Schmitz31-Jan-18 6:03 
QuestionDeploy desktop app with Target .net framwork 4 using Visual stuidio 2017 Pin
mhemant23-Jan-18 22:56
mhemant23-Jan-18 22:56 
QuestionStrange RadioButton Binding Problem Pin
Kevin Marois20-Jan-18 9:55
professionalKevin Marois20-Jan-18 9:55 
AnswerRe: Strange RadioButton Binding Problem Pin
Richard Deeming22-Jan-18 8:16
mveRichard Deeming22-Jan-18 8:16 
QuestionWPF Desktop client on Win XP Pin
mhemant18-Jan-18 1:20
mhemant18-Jan-18 1:20 
AnswerRe: WPF Desktop client on Win XP Pin
Jochen Arndt18-Jan-18 3:08
professionalJochen Arndt18-Jan-18 3:08 
QuestionWPF ComboBox Separator Style Problem Pin
Kevin Marois15-Jan-18 9:50
professionalKevin Marois15-Jan-18 9:50 
QuestionDividing a TextBox into columns Pin
Dwayne Barsotta6-Jan-18 16:47
Dwayne Barsotta6-Jan-18 16:47 
AnswerRe: Dividing a TextBox into columns Pin
Mycroft Holmes6-Jan-18 21:14
professionalMycroft Holmes6-Jan-18 21:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.