Click here to Skip to main content
14,271,712 members

.NET Framework

 
QuestionIs there any way to initialize or set values for this declaration as inline statement private IList<MockData<OnlineRegistration, OnlineRegistration, OnlineRegistration>> _registerMocks; Pin
simpledeveloper28-Mar-19 7:18
membersimpledeveloper28-Mar-19 7:18 
AnswerRe: Is there any way to initialize or set values for this declaration as inline statement private IList<MockData<OnlineRegistration, OnlineRegistration, OnlineRegistration>> _registerMocks; Pin
Eddy Vluggen29-Mar-19 2:33
mveEddy Vluggen29-Mar-19 2:33 
QuestionASP.Net 4.5 to ASP.Net core 2.0.1 migration issue of Authentication Pin
geetha naidu24-Mar-19 11:38
membergeetha naidu24-Mar-19 11:38 
QuestionMessage Closed Pin
6-Mar-19 21:25
memberMember 141739196-Mar-19 21:25 
AnswerRe: Data Science with Python environment setup Pin
Gerry Schmitz8-Mar-19 9:23
mveGerry Schmitz8-Mar-19 9:23 
GeneralRe: Data Science with Python environment setup Pin
Richard MacCutchan8-Mar-19 22:10
protectorRichard MacCutchan8-Mar-19 22:10 
GeneralRe: Data Science with Python environment setup Pin
Gerry Schmitz9-Mar-19 3:04
mveGerry Schmitz9-Mar-19 3:04 
QuestionWPF DataGridComboBoxColumn Binding Issue Pin
Saved By Grace28-Feb-19 4:47
memberSaved By Grace28-Feb-19 4:47 
I am building an application in WPF for the first time. The application is intended to track employees who are hired by the company, track the hire type (e.g…assignment category…full time, part time, seasonal, intern). In addition, it will track which department to which an employee is assigned during their tenure with the company. Some employees are exposed to several different departments while employed in order to more fully round out their training or due to work loads.

The backend for this application is built in SQL Server and contains three tables. They are company employees, company departments, and assignment categories. Each obviously has its own primary key.

I have created a datagrid that, via Linq to SQL Classes, displays data from the company employees table. Each of the columns in the datagrid is a DataGridTextColumn except for one which is a DataGridComboBoxColumn. The DataGridTextColumn’s work fine. However, I cannot seem to get the binding correct. The column appears in the datagrid and is a working combobox. The issue is that I cannot find how to populate the combox with values from which the end user will select. This combobox will allow the end user to choose which under which assignment category an employee has been hired.

As an end result, this application will be used by the company owner to keep track of the number of employees that he has on hand and show who will be leaving each month due to being a seasonal worker or an intern.

Below is the code behind and the xaml. Please note that I have spent several days now researching this topic and cannot find anything that I can make work. I am confident that this is because I am just learning xaml and c#.

Can someone help me understand what I am doing wrong, please?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;  
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 staff_scheduling_tool.views
{
  /// <summary>
  /// Interaction logic for employees_new_employee.xaml
  /// </summary>
  public partial class employees_new_employee : UserControl
{

assignment_typeDataContext dc = new assignment_typeDataContext(Properties.Settings.Default.db_employee_scheduling_applicationConnectionString);

  public employees_new_employee()
{
InitializeComponent();

  if (dc.DatabaseExists()) datagrid_search_results.ItemsSource = dc.companyemployees;

}
  private void Save_changes_Click(object sender, RoutedEventArgs e)
{
dc.SubmitChanges();
}
}
}


<DataGrid Name="datagrid_search_results" Margin="10,25" Width="1400" Height="350" AlternatingRowBackground="LightGreen" GridLinesVisibility="None" SelectionUnit="Cell" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" AutoGenerateColumns="False">
      <DataGrid.Columns>
      <DataGridTextColumn Binding="{Binding employee_id}" Width="Auto" Header=" Employee ID" />
      <DataGridTextColumn Binding="{Binding last_name}" Width="Auto" Header=" Last Name" SortDirection="Ascending" />
      <DataGridTextColumn Binding="{Binding first_name}" Width="Auto" Header=" First Name"/>
      <DataGridTextColumn Binding="{Binding middle_name}" Width="Auto" Header=" Middle Name"/>
      <DataGridTextColumn Binding="{Binding company_email}" Width="Auto" Header=" Company Email"/>
      <DataGridComboBoxColumn Width="Auto" Header="Assignment Category" />
      <DataGridTextColumn Binding="{Binding department_assignment_begin_date, StringFormat=d}" Width="Auto" Header=" Begin Date"/>
      <DataGridTextColumn Binding="{Binding department_assignment_end_date, StringFormat=d}" Width="Auto" Header=" End Date"/>
      </DataGrid.Columns>
      </DataGrid>
      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition Height="45"/>
      </Grid.RowDefinitions>
      <Button Name="save_changes" Content="Save Updates" Click="Save_changes_Click" Grid.Row="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="250" FontFamily="Sitka Banner" FontSize="24" FontStyle="Italic" FontWeight="ExtraBold"/>

      </Grid>


modified 28-Feb-19 17:42pm.

AnswerRe: WPF DataGridComboBoxColumn Binding Issue Pin
Gerry Schmitz28-Feb-19 10:59
mveGerry Schmitz28-Feb-19 10:59 
AnswerRe: WPF DataGridComboBoxColumn Binding Issue Pin
Saved By Grace28-Feb-19 15:06
memberSaved By Grace28-Feb-19 15:06 
GeneralRe: WPF DataGridComboBoxColumn Binding Issue Pin
Saved By Grace1-Mar-19 9:11
memberSaved By Grace1-Mar-19 9:11 
SuggestionRe: WPF DataGridComboBoxColumn Binding Issue Pin
FLYFLU20-Mar-19 15:30
memberFLYFLU20-Mar-19 15:30 
QuestionCOM Interop with latest .NET Framework Pin
JackMisani19-Feb-19 0:19
memberJackMisani19-Feb-19 0:19 
AnswerRe: COM Interop with latest .NET Framework Pin
Gerry Schmitz19-Feb-19 5:54
mveGerry Schmitz19-Feb-19 5:54 
GeneralRe: COM Interop with latest .NET Framework Pin
JackMisani19-Feb-19 6:29
memberJackMisani19-Feb-19 6:29 
QuestionMSIL: Are there practical uses for writing MSIL code that can't be done in C# Pin
nrnoble18-Feb-19 0:29
membernrnoble18-Feb-19 0:29 
AnswerRe: MSIL: Are there practical uses for writing MSIL code that can't be done in C# Pin
Richard Deeming18-Feb-19 1:19
mveRichard Deeming18-Feb-19 1:19 
QuestionTask based asyn Pin
anilkumar198612-Feb-19 18:50
memberanilkumar198612-Feb-19 18:50 
AnswerRe: Task based asyn Pin
Wastedtalent12-Feb-19 21:21
professionalWastedtalent12-Feb-19 21:21 
GeneralRe: Task based asyn Pin
anilkumar198612-Feb-19 21:37
memberanilkumar198612-Feb-19 21:37 
GeneralRe: Task based asyn Pin
Wastedtalent12-Feb-19 21:48
professionalWastedtalent12-Feb-19 21:48 
GeneralRe: Task based asyn Pin
anilkumar198612-Feb-19 22:52
memberanilkumar198612-Feb-19 22:52 
GeneralRe: Task based asyn Pin
anilkumar198613-Feb-19 1:23
memberanilkumar198613-Feb-19 1:23 
Questionstatement is not valid n a namespace Pin
Member 1384753912-Feb-19 8:07
memberMember 1384753912-Feb-19 8:07 
AnswerRe: statement is not valid n a namespace Pin
Richard Deeming12-Feb-19 10:05
mveRichard Deeming12-Feb-19 10:05 

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.