none
Ainhar a direita DATAGRID WPF RRS feed

Respostas

  • Wllington,

    Basta modificar o estilo do DataGridColumnHeader e definir a propriedade HorizontalAligment do ContentPresenter para Right, conforme exemplo abaixo:

    		<Style TargetType="{x:Type DataGridColumnHeader}">
    			<Setter Property="VerticalContentAlignment" Value="Center"/>
    			<Setter Property="Template">
    				<Setter.Value>
    					<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
    						<Grid>
    							<Microsoft_Windows_Themes:DataGridHeaderBorder BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsClickable="{TemplateBinding CanUserSort}" IsPressed="{TemplateBinding IsPressed}" IsHovered="{TemplateBinding IsMouseOver}" Padding="{TemplateBinding Padding}" SortDirection="{TemplateBinding SortDirection}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}">
    								<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Right"/>
    							</Microsoft_Windows_Themes:DataGridHeaderBorder>
    							<Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
    							<Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
    						</Grid>
    					</ControlTemplate>
    				</Setter.Value>
    			</Setter>
    		</Style>
    
    * basta adicionar esse código no resources para que todas as colunas sejam modificadas

     

    Att.,

    Marcelo

    quinta-feira, 26 de agosto de 2010 17:58
  • Olá Wnjesus,
    Você pode fazer também da seguinte maneira

    <ListView x:Name="lst">
       <ListView.View>
        <GridView x:Name="grd">
         <GridView.Columns>
          <GridViewColumn>
           <GridViewColumn.CellTemplate>
            <DataTemplate>
             <StackPanel HorizontalAlignment="Right">
              <TextBlock HorizontalAlignment="Right" Text="{Binding Path=Name}"/>
             </StackPanel>
            </DataTemplate>
           </GridViewColumn.CellTemplate>
          </GridViewColumn>
         </GridView.Columns>
        </GridView>
       </ListView.View>
      </ListView>
    
    Att.
    Anderson
    quinta-feira, 26 de agosto de 2010 19:22

Todas as Respostas

  • Wllington,

    Basta modificar o estilo do DataGridColumnHeader e definir a propriedade HorizontalAligment do ContentPresenter para Right, conforme exemplo abaixo:

    		<Style TargetType="{x:Type DataGridColumnHeader}">
    			<Setter Property="VerticalContentAlignment" Value="Center"/>
    			<Setter Property="Template">
    				<Setter.Value>
    					<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
    						<Grid>
    							<Microsoft_Windows_Themes:DataGridHeaderBorder BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsClickable="{TemplateBinding CanUserSort}" IsPressed="{TemplateBinding IsPressed}" IsHovered="{TemplateBinding IsMouseOver}" Padding="{TemplateBinding Padding}" SortDirection="{TemplateBinding SortDirection}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}">
    								<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Right"/>
    							</Microsoft_Windows_Themes:DataGridHeaderBorder>
    							<Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
    							<Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
    						</Grid>
    					</ControlTemplate>
    				</Setter.Value>
    			</Setter>
    		</Style>
    
    * basta adicionar esse código no resources para que todas as colunas sejam modificadas

     

    Att.,

    Marcelo

    quinta-feira, 26 de agosto de 2010 17:58
  • Olá Wnjesus,
    Você pode fazer também da seguinte maneira

    <ListView x:Name="lst">
       <ListView.View>
        <GridView x:Name="grd">
         <GridView.Columns>
          <GridViewColumn>
           <GridViewColumn.CellTemplate>
            <DataTemplate>
             <StackPanel HorizontalAlignment="Right">
              <TextBlock HorizontalAlignment="Right" Text="{Binding Path=Name}"/>
             </StackPanel>
            </DataTemplate>
           </GridViewColumn.CellTemplate>
          </GridViewColumn>
         </GridView.Columns>
        </GridView>
       </ListView.View>
      </ListView>
    
    Att.
    Anderson
    quinta-feira, 26 de agosto de 2010 19:22