Question

C# C#

Please leave commentary next to the code explaining what it does/

a WPF program that is still missing a file called Course.cs that defines a C# class called Course. Instances of the Course class are created and manipulated in the code behind of the WPF MainWindow window to allow the user to select courses of study and then update a list of selected courses.method that overrides the ToString() in order to be able to be displayed in a WPF window This method should be declared exactly as given below and then you should add your code to the body of the method to return the name field:

public override string ToString() { // this method should return the name field }

This is the code being used in the main window

2ing Systes.Collections.Generic using Systen.H5ndows-Insut uaang Syaus.hirden, Nedad. İMAKİK; g Systn.kandoShapes

CreateClassesObjs.MainWindow CreateClassesObjs 58 59 60 61 62 63 64 65 E private void button_Click (object sender, RoutedEven

This is what the output should look like.

Please select a course IT 328 IT 145 IT 200 IT 201 IT 270 IT 315 IT 328 IT 330 You have selected these course: Select this co

C# Please remember to put commentary next to the lines of code explaining what it does

2ing Systes.Collections.Generic using Systen.H5ndows-Insut uaang Syaus.hirden, "Nedad. İMAKİ"K; g Systn.kandoShapes
CreateClassesObjs.MainWindow CreateClassesObjs 58 59 60 61 62 63 64 65 E private void button_Click (object sender, RoutedEventArgs e) choice-(Course) (this.comboBox.SelectedItem); this.listBox. Items.Add(choice); 67 68
Please select a course IT 328 IT 145 IT 200 IT 201 IT 270 IT 315 IT 328 IT 330 You have selected these course: Select this course IT 145 IT 200 IT 315
0 0
Add a comment Improve this question Transcribed image text
Answer #1

----------------------I used Visual studio 2013, C# language, WPF Application-----------

------OUTPUT-----

8 Quick Launch (Ctri+Q DG WpfApplication (Running)-Microsoft Visual Studio (Administrator) FILE EDIT VIEW PROJECT BUILD DEBUG

FILE EDIT VIEW PROJECT BUILD DEBUG TEAM TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELPFull Screen 8 Quick Launch (Ctrl+ Q) P SigFILE EDIT VIEW PROJECT BUILD DEBUG TEAM TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELPFull Screen 8 Quick Launch (Ctrl+ Q) SignFILE EDIT VIEW PROJECT BUILD DEBUG TEAM TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELPFull Screen 8 Quick Launch (Ctrl+ Q) SignFILE EDIT VIEW PROJECT BUILD DEBUG TEAM TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELPFull Screen 8 Quick Launch (Ctrl+ Q) Sign

-------CODE-------

-------------Course.cs-------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfApplication
{
class Course
{
//Create a property called courseName to set and get course name
public string courseName { set; get; }

//Used ToString() method to get courseName
public override string ToString()
{
    return this.courseName;
}
}
}

--------MainWindow.xaml--------

<Window x:Class="WpfApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="62*"/>
<ColumnDefinition Width="301*"/>
<ColumnDefinition Width="154*"/>
</Grid.ColumnDefinitions>
<Label Content="Please select a course" FontWeight="Bold" HorizontalAlignment="Left" Margin="80.924,73,0,0" VerticalAlignment="Top" Height="31.97" Width="145.463" Grid.Column="1"/>
<ComboBox x:Name="cbFirst" HorizontalAlignment="Left" Margin="80.924,104.97,0,0" VerticalAlignment="Top" Width="146.866" Height="27" Grid.Column="1" SelectedIndex="0"/>
<Button Content="Select this course" HorizontalAlignment="Left" Margin="277.94,104.97,0,0" VerticalAlignment="Top" Width="142.164" Height="22.985" Grid.Column="1" Grid.ColumnSpan="2" Click="Button_Click"/>
<Label Content="You have selected these course" FontWeight="Bold" HorizontalAlignment="Left" Margin="83.73,183.791,0,0" VerticalAlignment="Top" Height="31.97" Width="199.194" Grid.Column="1"/>
<ListBox x:Name="LBsecond" Grid.Column="1" HorizontalAlignment="Left" Height="62.686" Margin="83.73,215.761,0,0" VerticalAlignment="Top" Width="142.657"/>

</Grid>
</Window>

-------MainWindow.xaml.cs------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
//Create a list of Course class to store each course name
List<Course> courses = new List<Course>();
public MainWindow()
{
InitializeComponent(); //Initialize all components
}

//When window about to load, this event occur.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//Create new course class to hold courseName and add that to List<Course> courses
courses.Add(new Course() { courseName = "IT 145" });
courses.Add(new Course() { courseName = "IT 200" });
courses.Add(new Course() { courseName = "IT 201" });
courses.Add(new Course() { courseName = "IT 270" });
courses.Add(new Course() { courseName = "IT 315" });
courses.Add(new Course() { courseName = "IT 328" });
courses.Add(new Course() { courseName = "IT 330" });

//Use foreach loop to iterate through List<Course> courses
foreach (Course item in courses)
{
//Add each courseName to combo box first using ToString() in Course.cs
cbFirst.Items.Add(item.ToString());
}
  
}

//When Select this course button is clicked, this event occurs
private void Button_Click(object sender, RoutedEventArgs e)
{
//Store the item in the combo box first into a variable called cName
string cName=cbFirst.SelectedItem.ToString();

//Check if list box already contains this course
if (LBsecond.Items.Contains(cName))
{
//If this course is already present in listbox, show a messagebox to user.
MessageBox.Show(cName+" already selected.");
}
else
{
//If listbox not contain this course, then add this course
LBsecond.Items.Add(cName);
}
  
}

}
}

Add a comment
Know the answer?
Add Answer to:
C# C# Please leave commentary next to the code explaining what it does/ a WPF program that is sti...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Greetings everyone I am having a little trouble with this one. I bolded my switch case...

    Greetings everyone I am having a little trouble with this one. I bolded my switch case which should work but its currently not. If a user selected course option 1 twice it just says you enrolled in course 1 and course 1. It should stop it by executing case -2. Need a new set of eyes. - Thanks using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleRegisterStudent { class Program { static void Main(string[] args) { (new...

  • so i have my c++ code and ive been working on this for hours but i...

    so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

  • Please help we are suppose to explain what the C code does. This is the electronics database (6 pts) This problem is...

    Please help we are suppose to explain what the C code does. This is the electronics database (6 pts) This problem is based on Electronics database. Add some annotations to the following table to explain what the C program is doing in detail. Note that "void" is how C declares a function that does not return anything. You are expected to generalize or research svntaxes not mentioned in the lecture C Program Annotation void newPCproduct EXEC SQL BEGIN DECLARE SECTION;...

  • 33 On May 6, Jim Ryan borrowed $14,000 from Lane Bank at 7 % interest. Jim...

    33 On May 6, Jim Ryan borrowed $14,000 from Lane Bank at 7 % interest. Jim plans to repay the loan on March 11. Assume the loan is on ordinary interest. How much will Jim repay on March 11? (Use Days in a year table) (Round your answer to the nearest cent.) Jm repay etbook 7-1 TABLE Exact days-in-a-year calendar (excluding leap year)" Day of month 30 31 30 31 28 31 30 31 31 30 31 31 Dec Mar...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

  • need help to complete this java program // add appropriate import statements here. // These imports...

    need help to complete this java program // add appropriate import statements here. // These imports you can leave as is. import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.stage.Stage; /** @author yourAccountNameHere */ public class ConnectTheDots extends Application {            /*     * Do not add code to main(). Add it below in connectTheDots instead.     */     public static void main(String[] args) {         launch(args);     }         /*...

  • please peovide coding in R: with a data of 13 variables and 200 observations Using the...

    please peovide coding in R: with a data of 13 variables and 200 observations Using the variable CLASS, test at 5% significance level to test the claim that the proportions of Freshmen, Sophomores, Juniors, and Seniors are the same. 2. Repeat part (a) for the variable COLLEGE. RLM ENGLISH MATH COMP 21 16 25 839SSESSOR 8 F 17 F N H ABCD 1 SEX HSP GPA AGE CREDITS CLASS COLLEGE MAJOR RESIDENCY TYPE 2 Transfer Blochm Resident F 75 2.39...

  • I need a basic program in C to modify my program with the following instructions: Create...

    I need a basic program in C to modify my program with the following instructions: Create a program in C that will: Add an option 4 to your menu for "Play Bingo" -read in a bingo call (e,g, B6, I17, G57, G65) -checks to see if the bingo call read in is valid (i.e., G65 is not valid) -marks all the boards that have the bingo call -checks to see if there is a winner, for our purposes winning means...

  • I have written my code for an employee management system that stores Employee class objects into...

    I have written my code for an employee management system that stores Employee class objects into a vector, I am getting no errors until I try and compile, I am getting the error: C2679 binary '==': no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion). But I am not sure why any help would be great, Thank you! 1 2 3 4 5 6 7 8 9 10 11 12 13...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT