Jump to content

Recommended Posts

Posted

olá!

bem estou aqui a tentar usar um datagrid, não sou muito familiarizada com este controlo, pois normalmente uso listview!

Tenho duas questões:

1º Relativamente as GridLines:

uso as seguintes propriedades (XAML)

 HorizontalGridLinesBrush="White"
VerticalGridLinesBrush="White"
GridLinesVisibility="None"

e quando a row não está seleccionada, não me aparece as gridlines ( como é obvio pelo que defini!)

O problema está, que quando selecciono uma row, aparece as linhas a volta...  😛

Terei que alterar o CellStyle? ou CellTemplate?  isto implica a alterar o style do controlo de edição....não é?

2º Relativamente ao alinhamento do texto no header da coluna

não consegui obter uma propriedade para alinhar o texto do header da coluna...será que vi mal? ou terei que alterar o HeaderTemplate ( algo do género ) ?

obrigada pela atenção

tofas

Posted

Em vez de White experimenta por Transparent. Mas provavelmente as linhas que aparecem não é da gridview mas sim de estar seleccionado. E ai provavelmente é alterando o style ou template do item.

Provavelmente terás que definir o template, mas não sei de cor pode ser que haja uma propriedade.

"Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !"

Sign on a computer system consultant's desk

Posted

boas,

e as respostas ao que pretendia:

....
xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
.....
<Window.Resources>
        <Style x:Key="dgHeaderStyle" TargetType="toolkit:DataGridColumnHeader">
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />   
            <Setter Property="Cursor" Value="Hand" />
        </Style>

        <Style x:Key="dgCellStyle" TargetType="toolkit:DataGridCell"
                   BasedOn="{StaticResource {x:Type toolkit:DataGridCell}}">      
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="Blue" />
                    <Setter Property="BorderBrush" Value="Transparent" />
                    <Setter Property="Foreground" Value="White" />
                </Trigger>               
            </Style.Triggers>
        </Style>        
    </Window.Resources>

........

<toolkit:DataGrid Background="White"                              
                                 GridLinesVisibility="None"
                                 AutoGenerateColumns="False" 
                                 CanUserAddRows="False"
                                 CanUserReorderColumns="True" 
                                 CanUserSortColumns="False"                                 
                                 Grid.Column="5" Grid.Row="1" 
                                 Name="dataGridCurrentElements"  
                                 SelectionMode="Extended"
                                 CellStyle="{StaticResource dgCellStyle}"
                                 ColumnHeaderStyle="{StaticResource dgHeaderStyle}"                                                              
                                 SelectionChanged="dataGridCurrentElements_SelectionChanged">   

Bom trabalho

tofas

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.