Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends.

i am using data grid in uwp application after installing external package from the nuGet.

now problem is i cant able to give the style fro the data grid in UWP :( i tried so may times. :(

even on internet i cant the solution fro this.

what i want to do :

1. i want change the header font and background color.
2. i want to change the color after selecting the row.
3. i want to give a border to the data grid with rounded corners.

please help me.. :(



thanks in advance :(

What I have tried:

<controls:DataGrid AutoGenerateColumns="False"    CanUserResizeColumns="False" IsReadOnly="True" Margin="31,21,103,483" Name="UserListView" VerticalScrollBarVisibility="Auto"  UseLayoutRounding="True" HorizontalScrollBarVisibility="Auto" TabIndex="4" FontSize="14" Background="White"
   HeadersVisibility="Column"   SelectedIndex="0" HorizontalGridLinesBrush="#E1E1E1" IsTabStop="True" RenderTransformOrigin="0.504,0.739" Grid.Row="2" BorderBrush="#E1E1E1" BorderThickness="1" Grid.Column="2" Grid.ColumnSpan="7" >

    <controls:DataGrid.Columns   >

      <controls:DataGridTemplateColumn     CanUserReorder="False" CanUserResize="False" Width="50" x:Name="userCheckBox" >
            <controls:DataGridTemplateColumn.CellTemplate >
                <DataTemplate>
                    <CheckBox  Foreground="#444444" Height="10" Width="10" Margin="15,10,0,10"   x:Name="IndvCheckBox" DataContext="{Binding userId}" Unchecked="UserUnchecked"  Checked="UserChecked"  UseLayoutRounding="True">

                    </CheckBox>
                </DataTemplate>
            </controls:DataGridTemplateColumn.CellTemplate>
        </controls:DataGridTemplateColumn>

        <controls:DataGridTemplateColumn  CanUserReorder="False" CanUserResize="False"   Header="Name" Width="380"  >
            <controls:DataGridTemplateColumn.CellTemplate   >
                <DataTemplate>
                    <TextBlock  Margin="10,20,0,10"  x:Name="NameTextBox" Foreground="#444444" FontSize="12" FontFamily="Montserrat" >
                        <Run Text="{Binding userPrefix}" />
                        <Run Text="{Binding userFirstName}" />
                        <Run Text="{Binding userLastName}" />
                    </TextBlock>
                </DataTemplate>
            </controls:DataGridTemplateColumn.CellTemplate>
        </controls:DataGridTemplateColumn>

    <controls:DataGridTemplateColumn  CanUserReorder="False" CanUserResize="False"   Header="Email" Width="380" >
            <controls:DataGridTemplateColumn.CellTemplate >
                <DataTemplate>
                    <TextBlock  Margin="10,20,0,10" Text="{Binding userEmail}" x:Name="NameTextBox" Foreground="#444444" FontSize="12" FontFamily="Montserrat" />
                </DataTemplate>
            </controls:DataGridTemplateColumn.CellTemplate>
        </controls:DataGridTemplateColumn>

        <controls:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False"  Header="Phone" Width="250" >
            <controls:DataGridTemplateColumn.CellTemplate >
                <DataTemplate>
                    <TextBlock  FontSize="12" Margin="10,20,0,10"  Text="{Binding userPhone}"   Foreground="#444444" FontFamily="Montserrat"/>
                </DataTemplate>
            </controls:DataGridTemplateColumn.CellTemplate>
        </controls:DataGridTemplateColumn>

        <controls:DataGridTemplateColumn Tag="Col" Header="Update" Width="*">
            <controls:DataGridTemplateColumn.CellTemplate >
                <DataTemplate>
              <Image HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,20,0,10" Height="15" DataContext="{Binding userId}"  Width="15" Source="Images/Edit.png" Tapped="GridUpdateBtnClick"  />
                </DataTemplate>
            </controls:DataGridTemplateColumn.CellTemplate>
        </controls:DataGridTemplateColumn>

    </controls:DataGrid.Columns>
</controls:DataGrid>
Posted
Updated 2-Aug-19 0:44am
v2
Comments
[no name] 28-Feb-19 12:14pm    
Clean up your code and ask one question at a time. We have answers but you are making things difficult.
ketan Ram Patil 28-Feb-19 23:06pm    
thank you for your valuable reply. i want to change the datagrid header font and background.

1 solution

 
Share this answer
 
Comments
ketan Ram Patil 1-Mar-19 5:20am    
thank you for your reply. i referred above links. would you please give me any data grid style example in uwp xamarin in xaml format. :(

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