Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
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?
 
 <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-Feb-13 2:46am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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>
  Permalink  
Comments
Coruscus at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100