本文介绍了如何在uwp xamarin(xaml)中为数据网格提供样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友。



i在从nuGet安装外部包后,在uwp应用程序中使用数据网格。



现在的问题是我无法在UWP中为数据网格提供样式:(我试过这样的时间。:(



即使在互联网上我也不能这个解决方案。



我想做什么:



1.我想改变标题字体和背景颜色。

2.我想在选择行后更改颜色。

3.我想给带圆角的数据网格边框。



请帮帮我.. :(







提前感谢:(



我尝试了什么:



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>

推荐答案


这篇关于如何在uwp xamarin(xaml)中为数据网格提供样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:36