Click here to Skip to main content
15,887,485 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Textbox Undo Pin
Pete O'Hanlon9-May-12 10:46
mvePete O'Hanlon9-May-12 10:46 
Questionbind data from dattable with datagrid Pin
MemberDotNetting9-May-12 4:29
MemberDotNetting9-May-12 4:29 
QuestionSave DocumentViewer content as MS Word document Pin
sureshb_079-May-12 1:51
professionalsureshb_079-May-12 1:51 
QuestionResize and Edit Text in wpf Pin
NoufMohd8-May-12 1:17
NoufMohd8-May-12 1:17 
AnswerRe: Resize and Edit Text in wpf Pin
Mycroft Holmes8-May-12 12:29
professionalMycroft Holmes8-May-12 12:29 
Questiontry to add data on wpf DataGridColumn Pin
MemberDotNetting7-May-12 10:55
MemberDotNetting7-May-12 10:55 
AnswerRe: try to add data on wpf DataGridColumn Pin
Mycroft Holmes7-May-12 12:26
professionalMycroft Holmes7-May-12 12:26 
AnswerRe: try to add data on wpf DataGridColumn Pin
Wayne Gaylard7-May-12 20:09
professionalWayne Gaylard7-May-12 20:09 
The issue is that you are setting the AutoGenerateColumns property of the DataGrid to true, which will generate it's own columns (one for each field in the datatable) as well as show your template columns (which are not bound to anything by the way, so will not display any results). You have 2 options here:-
1. Forget about your template columns, and leave AutoGenerateColumns on. Then in your SQL query you should only select the columns you want displayed, and use aliases to get the correct headers for your columns i.e.
SQL
SELECT name AS Name, emailaddress AS Address FROM youtable
. This will give you the results you want except for column width.
2. Turn AutoGenerateColumns off in your DataGrid, and the use the DisplayMemberBinding property of your template columns to bind the column to the datatable field i.e
<DataGridTemplateColumn Header="Adress" DisplayMemnerBinding={Binding Path=emailaddress} Width="500" IsReadOnly="True">
. This will also get you your desired result with column widths.

Personally I never use DataTables to bind to WPF controls, preferring to have a class that holds my object properties, and then having an ObservableCollection of that class that holds all instances of that class to bind to the DataGrid.

Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

GeneralRe: try to add data on wpf DataGridColumn Pin
MemberDotNetting7-May-12 23:23
MemberDotNetting7-May-12 23:23 
QuestionWPF DataGrid cell click Pin
LAPEC7-May-12 9:27
LAPEC7-May-12 9:27 
Questionwpf ritchbox Pin
MemberDotNetting6-May-12 3:41
MemberDotNetting6-May-12 3:41 
AnswerRe: WPF RichTextBox Pin
Wayne Gaylard6-May-12 21:07
professionalWayne Gaylard6-May-12 21:07 
Questionadd wpf user control Pin
MemberDotNetting4-May-12 22:22
MemberDotNetting4-May-12 22:22 
AnswerRe: add wpf user control Pin
Abhinav S5-May-12 21:40
Abhinav S5-May-12 21:40 
QuestionWPF DataGrid cell click Pin
LAPEC4-May-12 1:06
LAPEC4-May-12 1:06 
AnswerRe: WPF DataGrid cell click Pin
Erik Rude4-May-12 1:31
Erik Rude4-May-12 1:31 
GeneralRe: WPF DataGrid cell click Pin
LAPEC4-May-12 1:51
LAPEC4-May-12 1:51 
GeneralRe: WPF DataGrid cell click Pin
Erik Rude4-May-12 2:46
Erik Rude4-May-12 2:46 
AnswerRe: WPF DataGrid cell click Pin
Jeremy Hutchinson4-May-12 2:46
professionalJeremy Hutchinson4-May-12 2:46 
Questionuser control Pin
MemberDotNetting3-May-12 13:40
MemberDotNetting3-May-12 13:40 
AnswerRe: user control Pin
Jeremy Hutchinson4-May-12 2:34
professionalJeremy Hutchinson4-May-12 2:34 
AnswerRe: user control Pin
Alisaunder6-May-12 2:23
Alisaunder6-May-12 2:23 
QuestionHow to get the value of textbox in ViewModel in WPF - MVVM Pin
Rocky#3-May-12 4:02
Rocky#3-May-12 4:02 
AnswerRe: How to get the value of textbox in ViewModel in WPF - MVVM Pin
Jeremy Hutchinson3-May-12 5:30
professionalJeremy Hutchinson3-May-12 5:30 
GeneralRe: How to get the value of textbox in ViewModel in WPF - MVVM Pin
Rocky#3-May-12 20:42
Rocky#3-May-12 20:42 

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.