Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an issue with aligning the content in the second column to the top of the cell and to the right of it. I wish for it to be aligned level with the top line of the message column when the message content is forced to be wrapped. I made an orange border and the cell seems to remain the height and width of the content, is there any way to force the name cell height to be that of the message cell?

HTML
<ScrollViewer x:Name="svwViewer" Grid.Row="1">
           <ListView x:Name="grdContent" ScrollViewer.CanContentScroll="False" removed="#FF171717" BorderThickness="0,0,0,0">
               <ListView.View>
                   <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource NoHeaderStyle}">
                       <GridViewColumn DisplayMemberBinding="{Binding colTime}" />
                       <GridViewColumn>
                           <GridViewColumn.CellTemplate>
                               <ItemContainerTemplate>
                                   <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="Orange" BorderThickness="1">
                                       <Grid HorizontalAlignment="Right" VerticalAlignment="Top">
                                           <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="#FFEEEEEE" Text="{Binding colUser}"/>
                                       </Grid>
                                   </Border>
                               </ItemContainerTemplate>
                           </GridViewColumn.CellTemplate>
                       </GridViewColumn>
                       <GridViewColumn>
                           <GridViewColumn.CellTemplate>
                               <DataTemplate>
                                   <TextBlock TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Top" Foreground="#FFEEEEEE" Text="{Binding colMessage}" />
                               </DataTemplate>
                           </GridViewColumn.CellTemplate>
                       </GridViewColumn>
                   </GridView>
               </ListView.View>
           </ListView>
       </ScrollViewer>


Here's a preview of what it looks like at the moment. As you can see the "TestUser" is not level with the top of the wrapped message. Any ideas?

http://i.imgur.com/b3GgLZC.png
Posted

1 solution

It looks like you are setting the vertical alignment to "Top" on your Textbox.

What you should be doing is setting that vertical alignment on your DataGrid Cells. If I am understanding your question correctly, you want that textbox shifted upward.

If you want to see this behavior in all datagrid cells. I would suggest making it a style.

<style>

</style>
 
Share this answer
 
Comments
Coruscus 1-Feb-13 9:45am    
That works fine for a datagrid, given there's a type 'DataGridCell', however, there is not a cell type for GridView, and I can't seem to find anywhere I can apply a style to in hope of achieving that effect.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900