Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit RightAlign in DataGrid Row
7 replies. Latest Post by dunirvana on November 9, 2009.
(0)
dunirvana
Member
6 points
14 Posts
11-06-2009 11:00 AM |
Im using this code
<data:DataGridTemplateColumn Header="Code"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding codEmp}" HorizontalAlignment="Right" /> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn>
Is perfect but i cant update the cell, what im doing wrong?
bryant
Star
9937 points
1,629 Posts
11-06-2009 11:08 AM |
Use a TextBox instead of a TextBlock. TextBlocks are read only.
11-06-2009 11:38 AM |
Now works, but now in the cells i have squares, as if were placed in there, exist a way improve the appearance, for the cells become equal to line?
11-06-2009 1:43 PM |
You can fully style the textbox. Another solution would be to use in-place editing.
11-06-2009 2:14 PM |
Thanks for the help again bryant, the Nikhil article is very good, but my datagrid have diferent colors for the rows, the style eliminate the borders from the textbox but i dont know how paint then with the color of the row. I dont understand why dont exist a simple way to do this.
11-06-2009 2:24 PM |
Try setting the BorderThickness="0" to see if that gives you want you want.
yifung
Contributor
3313 points
540 Posts
11-06-2009 8:09 PM |
Leave the CellTemplate a TextBlock but add a CellEditingTemplate that has a TextBox
11-09-2009 7:08 AM |
Thank you for your attention, bryant and Yifung, the Yifung solution works, the code:
<data:DataGridTemplateColumn Header="Code"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding cod}" HorizontalAlignment="Right"/> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> <data:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <TextBox Text="{Binding cod, Mode=TwoWay}" HorizontalAlignment="Right"/> </DataTemplate> </data:DataGridTemplateColumn.CellEditingTemplate> </data:DataGridTemplateColumn>