Click here to Skip to main content
16,017,857 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Best book(s) on WPF Pin
Gerry Schmitz20-Nov-18 7:00
mveGerry Schmitz20-Nov-18 7:00 
QuestionWPF - HELP with datepicker Pin
Member 1069141114-Nov-18 3:18
Member 1069141114-Nov-18 3:18 
SuggestionRe: WPF - HELP with datepicker Pin
Richard Deeming14-Nov-18 6:27
mveRichard Deeming14-Nov-18 6:27 
QuestionButton Style Question Pin
Kevin Marois6-Nov-18 4:26
professionalKevin Marois6-Nov-18 4:26 
AnswerRe: Button Style Question Pin
Super Lloyd19-Nov-18 14:44
Super Lloyd19-Nov-18 14:44 
QuestionHow to call "customized" mahapps.metro modal-dialog window? Pin
Pew_new24-Sep-18 6:50
Pew_new24-Sep-18 6:50 
AnswerRe: How to call "customized" mahapps.metro modal-dialog window? Pin
Super Lloyd19-Nov-18 14:59
Super Lloyd19-Nov-18 14:59 
QuestionCreating DataGrid IN Code Behind Pin
Kevin Marois19-Sep-18 13:00
professionalKevin Marois19-Sep-18 13:00 
XAML
<DataGrid Grid.Row="1"
            x:Name="dataGrid"
            AutoGenerateColumns="False"
            BorderBrush="SteelBlue"
            BorderThickness="1"
            Margin="5"/>

Code Behind
private ObservableCollection<DataGridColumn> _ColumnCollection;
public ObservableCollection<DataGridColumn> ColumnCollection
{
    get { return _ColumnCollection; }
    set
    {
        if (_ColumnCollection != value)
        {
            _ColumnCollection = value;
            RaisePropertyChanged("ColumnCollection");
        }
    }
}

private DataTable _Datatable;
public DataTable Datatable
{
    get { return _Datatable; }
    set
    {
        if (_Datatable != value)
        {
            _Datatable = value;
            RaisePropertyChanged("Datatable");
        }
    }
}

private void CreateGrid()
{
    Datatable = new DataTable();
    ColumnCollection = new ObservableCollection<DataGridColumn>();

    Datatable.Columns.Add("Fruit", typeof(string));

    Datatable.Rows.Add("Apples");
    Datatable.Rows.Add("Oranges");
    Datatable.Rows.Add("Grapes");

    dataGrid.Columns.Add(new DataGridTextColumn()
    {
        Header = "Fruit Name",
        Width = new DataGridLength(200),
        FontSize = 12,
        Binding = new Binding("Fruit")
    });

    var row = Datatable.Rows[0];

    dataGrid.ItemsSource = Datatable.Rows;
}

I see the column called Fruit Name, and there are 3 data rows, yet I don't see the data.

The Output Window shows 6 lines like this:
System.Windows.Data Error: 40 : BindingExpression path error: 'Fruit' property not found on 'object' ''DataRow' (HashCode=51379511)'. BindingExpression:Path=Fruit; DataItem='DataRow' (HashCode=51379511); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

What am I doing wrong??
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: Creating DataGrid IN Code Behind Pin
Gerry Schmitz24-Sep-18 6:34
mveGerry Schmitz24-Sep-18 6:34 
QuestionCreating DataGrid IN Code Behind Pin
Kevin Marois19-Sep-18 13:00
professionalKevin Marois19-Sep-18 13:00 
QuestionListBox UserControl Binding Problelm Pin
Kevin Marois18-Sep-18 12:03
professionalKevin Marois18-Sep-18 12:03 
AnswerRe: ListBox UserControl Binding Problelm Pin
Richard Deeming19-Sep-18 8:14
mveRichard Deeming19-Sep-18 8:14 
GeneralRe: ListBox UserControl Binding Problelm Pin
Kevin Marois19-Sep-18 8:58
professionalKevin Marois19-Sep-18 8:58 
QuestionDynamically Created DataGrids Binding Problem Pin
Kevin Marois17-Sep-18 6:44
professionalKevin Marois17-Sep-18 6:44 
AnswerRe: Dynamically Created DataGrids Binding Problem Pin
Gerry Schmitz17-Sep-18 15:00
mveGerry Schmitz17-Sep-18 15:00 
QuestionWPF MVVM textbox bind to SelectedItem issue Pin
miniboom6-Sep-18 3:32
miniboom6-Sep-18 3:32 
AnswerRe: WPF MVVM textbox bind to SelectedItem issue Pin
Mycroft Holmes6-Sep-18 12:47
professionalMycroft Holmes6-Sep-18 12:47 
GeneralRe: WPF MVVM textbox bind to SelectedItem issue Pin
miniboom7-Sep-18 5:40
miniboom7-Sep-18 5:40 
GeneralRe: WPF MVVM textbox bind to SelectedItem issue Pin
Mycroft Holmes7-Sep-18 11:15
professionalMycroft Holmes7-Sep-18 11:15 
QuestionPlease help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 10:00
Pew_new4-Sep-18 10:00 
AnswerRe: Please help me to figure out a purpose of this code. Pin
Mycroft Holmes4-Sep-18 11:29
professionalMycroft Holmes4-Sep-18 11:29 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 18:31
Pew_new4-Sep-18 18:31 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Mycroft Holmes4-Sep-18 19:18
professionalMycroft Holmes4-Sep-18 19:18 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 22:25
Pew_new4-Sep-18 22:25 
AnswerRe: Please help me to figure out a purpose of this code. Pin
Richard MacCutchan4-Sep-18 21:52
mveRichard MacCutchan4-Sep-18 21:52 

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.