Skip to main content

Microsoft Silverlight

Answered Question RightAlign in DataGrid RowRSS Feed

(0)

dunirvana
dunirvana

Member

Member

6 points

14 Posts

RightAlign in DataGrid Row

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?

------
O coração tem razões que a própria razão desconhece
---

bryant
bryant

Star

Star

9937 points

1,629 Posts

Silverlight MVP

Re: RightAlign in DataGrid Row

Use a TextBox instead of a TextBlock. TextBlocks are read only.

-- bryant

Blog | Twitter
_________________
Dont forget to click "Mark as Answer" on the post that helped you.

dunirvana
dunirvana

Member

Member

6 points

14 Posts

Re: Re: RightAlign in DataGrid Row

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?

------
O coração tem razões que a própria razão desconhece
---

bryant
bryant

Star

Star

9937 points

1,629 Posts

Silverlight MVP

Re: Re: Re: RightAlign in DataGrid Row

You can fully style the textbox. Another solution would be to use in-place editing.

-- bryant

Blog | Twitter
_________________
Dont forget to click "Mark as Answer" on the post that helped you.

dunirvana
dunirvana

Member

Member

6 points

14 Posts

Re: Re: Re: Re: RightAlign in DataGrid Row

 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.

------
O coração tem razões que a própria razão desconhece
---

bryant
bryant

Star

Star

9937 points

1,629 Posts

Silverlight MVP

Re: Re: Re: Re: Re: RightAlign in DataGrid Row

Try setting the BorderThickness="0" to see if that gives you want you want.

-- bryant

Blog | Twitter
_________________
Dont forget to click "Mark as Answer" on the post that helped you.

yifung
yifung

Contributor

Contributor

3313 points

540 Posts

Microsoft
Answered Question

Re: RightAlign in DataGrid Row

Leave the CellTemplate a TextBlock but add a CellEditingTemplate that has a TextBox

Yifung Lin [MSFT]

dunirvana
dunirvana

Member

Member

6 points

14 Posts

Answered Question

Re: RightAlign in DataGrid Row

 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>

  

 

------
O coração tem razões que a própria razão desconhece
---
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities