Register for your free account! | Forgot your password?

You last visited: Today at 08:56

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



WPF C#

Discussion on WPF C# within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2012
Posts: 372
Received Thanks: 21
WPF C#

I am starting with WPF and have a question,...how do i make this:
if i click on an item TreeView that different items would be displayed in ListView, depended on what is selected in TreeView.

for example, in a mail application, if i click on inbox (TreeView), inbox messages should be listed in ListView, same for Sent,... etc..

If anyone could link me a good example that explains this, i googled but wasnt successful too much,...
Hikarim is offline  
Old 03/24/2015, 19:37   #2


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
You can do that with frameworks that use event piping such as .
Mostey is offline  
Old 03/25/2015, 13:42   #3
 
elite*gold: 0
Join Date: Apr 2012
Posts: 372
Received Thanks: 21
what would be a good overall book to learn WPF? feel like i dont learn all that much in school :S
Hikarim is offline  
Old 03/25/2015, 14:47   #4
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
You don't need a 3rd party lib for that. Simply implement MVVM and done.

I'd suggest you to stop by at microsofts virtual academy, they have amazing stuff
Xio. is offline  
Old 03/25/2015, 16:30   #5
 
elite*gold: 0
Join Date: Apr 2012
Posts: 372
Received Thanks: 21
Okay, thanks i have a question though, with the OpenFileDialog,... for now we have to just add it to the menu so it shows up and add a filter to it (doesnt have to do stuff yet), but if i press cancel the whole application closes instead of just the OpenFileDialog,...
how can i fix that?

my code atm:
Code:
            OpenFileDialog odpri = new OpenFileDialog();
            odpri.Multiselect = false;
            odpri.Filter = "XML Files (*.xml)|*.xml";
            odpri.ShowDialog();
Hikarim is offline  
Old 03/25/2015, 20:47   #6


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
Quote:
Originally Posted by Xio. View Post
You don't need a 3rd party lib for that. Simply implement MVVM and done.

I'd suggest you to stop by at microsofts virtual academy, they have amazing stuff
Of course you don't need it but it would be advisable, though. Implementing the MVVM boiler plate code really isn't that great. I'd advise to only do that when learning how things work. Otherwise you really should work with frameworks that do handle much things easier and keep away the boiler plate.

By the way: How'd you do that if you seperate both ViewModels from each other? The ViewModel for the current inbox item needs to be parented to the ListView which actually doesn't make much sense. Event piping comes in really handy here because no composition is required.

Quote:
Originally Posted by Hikarim View Post
what would be a good overall book to learn WPF? feel like i dont learn all that much in school :S
Schools teach WPF? Guess that's out of my scope, I've never had teachers that have done more than the absolute basics of the basics.

Quote:
Originally Posted by Hikarim View Post
Okay, thanks i have a question though, with the OpenFileDialog,... for now we have to just add it to the menu so it shows up and add a filter to it (doesnt have to do stuff yet), but if i press cancel the whole application closes instead of just the OpenFileDialog,...
how can i fix that?

my code atm:
Code:
            OpenFileDialog odpri = new OpenFileDialog();
            odpri.Multiselect = false;
            odpri.Filter = "XML Files (*.xml)|*.xml";
            odpri.ShowDialog();
Where do you run that code? This code can't be the cause for this problem, except it is run in a cancel event or anything other that automatically closes the application after executing the function code.
Mostey is offline  
Old 03/25/2015, 20:51   #7
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
Quote:
Originally Posted by Mostey View Post
.... I'd advise to only do that when learning how things work....
Now read his question again and tell me he's a professional.
Xio. is offline  
Old 03/25/2015, 21:26   #8
 
elite*gold: 0
Join Date: Apr 2012
Posts: 372
Received Thanks: 21
Nope, im not pro, i just had 1st lesson in school

the OpenFileDialog,... we just have to add it to the mebu in our app,... just so its tehre, no real use yet,...but when i run the app, and go to File->Open .. and then the OpenFIleDialog appears,... and if i click on ok or cancel, the whole application closes,...instread of just the OpenFileDialog

so i have it like this:
Code:
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openit = new OpenFileDialog();
            openit.Multiselect = false;
            openit.Filter = "XML Files (*.xml)|*.xml";
            openit.ShowDialog();
            
        }
Hikarim is offline  
Old 03/25/2015, 22:15   #9
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
Quote:
Originally Posted by Hikarim View Post
Nope, im not pro, i just had 1st lesson in school

the OpenFileDialog,... we just have to add it to the mebu in our app,... just so its tehre, no real use yet,...but when i run the app, and go to File->Open .. and then the OpenFIleDialog appears,... and if i click on ok or cancel, the whole application closes,...instread of just the OpenFileDialog

so i have it like this:
Code:
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openit = new OpenFileDialog();
            openit.Multiselect = false;
            openit.Filter = "XML Files (*.xml)|*.xml";
            openit.ShowDialog();
            
        }
PHP Code:
OpenFileDialog openit = new OpenFileDialog();

            
openit.Multiselect false;
            
openit.Filter "XML Files (*.xml)|*.xml";
DialogResult result openit.ShowDialog();
        if (
result == DialogResult.OK// Test result.
        
{
//Code if file was selected
        
}
//no file selected (pressed cancel) 


^ Bookmark dotnetpearls, great stuff
Xio. is offline  
Old 03/26/2015, 08:11   #10


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
Quote:
Originally Posted by Hikarim View Post
Nope, im not pro, i just had 1st lesson in school

the OpenFileDialog,... we just have to add it to the mebu in our app,... just so its tehre, no real use yet,...but when i run the app, and go to File->Open .. and then the OpenFIleDialog appears,... and if i click on ok or cancel, the whole application closes,...instread of just the OpenFileDialog

so i have it like this:
Code:
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openit = new OpenFileDialog();
            openit.Multiselect = false;
            openit.Filter = "XML Files (*.xml)|*.xml";
            openit.ShowDialog();
            
        }
As I've said before, this code is not causing this behavior. There must be something other that closes/terminates the application if this event occurs. You should verify that by testing the OFD in another (blank) WPF project.
Mostey is offline  
Reply




All times are GMT +1. The time now is 08:59.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.