DevExpress的提供的内置,可以应用到主题GridControl改变其外观。

 

主题

iOS版

Android版


(默认适用于iOS)

黑暗
(默认为Android)

应用预定义的主题

主题类存储提供的主题名称。要更改主题,分配主题类的相应字段的ThemeManager.ThemeName

 

 
 

C#

  

using Xamarin.Forms;

using DevExpress.Mobile.DataGrid.Theme;

 
 

// ...  

 
 

ThemeManager.ThemeName = Themes.Dark;

 
 

// ...  

 
 

自定义主题

要自定义应用的主题,使用ThemeBase类。它为您提供各种定制,使您可以更改主题的外观,并将其应用到电网。您可以使用这些定制来改变背景颜色,字体和所需的网格单元(头,属性组行等)

重要

要应用定制,调用ThemeManager.RefreshTheme方法。

ThemeBase类的属性提供访问不同的定制,你可以调整来改变外观设置(例如,字体属性,边框和背景颜色等)网格的相应的视觉元素(如数据单元格,行分组过滤器面板等)。在本实施例中,使用下面的定制。

 
 

为了跟踪时刻变化的主题,无论是处理ThemeManager.ThemeChanged事件或使用IThemeChangingHandler.OnThemeChanged方法。

这个例子定制光主题,因为它是在下面的图片中显示。

 
 

 

 
 

C#:MainPage.xaml.cs

  

using System;

using System.Collections.Generic;

using Xamarin.Forms;

using DevExpress.Mobile.DataGrid;

using DevExpress.Mobile.DataGrid.Theme;

 
 

namespace ThemeCustomizing {

 
 

public
partial
class MainPage : ContentPage {

 
 

int count = 0;

public MainPage() {

 
 

InitializeComponent();

 
 

 
 

TestOrdersRepository model = new TestOrdersRepository();

BindingContext = model;

 
 

ThemeManager.ThemeName = Themes.Light;

 
 

// Header customization.

ThemeManager.Theme.HeaderCustomizer.BackgroundColor = Color.FromRgb(187, 228, 208);

ThemeFontAttributes myFont = new ThemeFontAttributes("Verdana",

ThemeFontAttributes.FontSizeFromNamedSize(NamedSize.Large),

FontAttributes.None, Color.White);

ThemeManager.Theme.HeaderCustomizer.Font = myFont;

 
 

 
 

// Cell customization.

ThemeManager.Theme.CellCustomizer.SelectionColor = Color.FromRgb(186, 220, 225);

ThemeFontAttributes myFont1 = new ThemeFontAttributes("Verdana",

ThemeFontAttributes.FontSizeFromNamedSize(NamedSize.Medium),

FontAttributes.None, Color.Black);

ThemeManager.Theme.CellCustomizer.Font = myFont1;

 
 

 
 

// Various customization.

ThemeManager.Theme.TotalSumaryCustomizer.BackgroundColor = Color.FromRgb(163, 162, 168);

ThemeFontAttributes myFont2 = new ThemeFontAttributes("Verdana",

ThemeFontAttributes.FontSizeFromNamedSize(NamedSize.Default),

FontAttributes.None, Color.Black);

ThemeManager.Theme.TotalSummaryCustomizer.Font = myFont2;

ThemeManager.Theme.NewItemRowCustomizer.Font = myFont2;

 
 

 
 

ThemeManager.RefreshTheme();

}

 
 

void OnCalculateCustomSummary(object sender, CustomSummaryEventArgs e) {

if (e.FieldName.ToString() == "Shipped")

if (e.IsTotalSummary) {

if (e.SummaryProcess == CustomSummaryProcess.Calculate) {

if (!(bool)e.FieldValue)

count++;

e.TotalValue = count;

}

}

}

 
 

}

 
 

}

自定义模板列、滑动显示按钮

<dxGrid:GridControl
x:Name="grid"
ItemsSource="{Binding JDProduct}"

AllowResizeColumns="True"

AllowHorizontalScrollingVirtualization="True"

ColumnsAutoWidth="False"

SwipeButtonShowing="OnSwipeButtonShowing"


SwipeButtonClick="OnSwipeButtonClick"

>

<dxGrid:GridControl.Columns>

<dxGrid:TemplateColumn
FieldName="Name"
Caption ="112"
Width ="60"
IsReadOnly="true"
AllowGroup="False"
AllowSort="False" >

<dxGrid:TemplateColumn.DisplayTemplate>

<DataTemplate>

<Button
Text="{Binding Value}"

Clicked="nameClient"

BorderWidth="0"

                                    BackgroundColor="Green"

                                    TextColor="White"

></Button>

</DataTemplate>

</dxGrid:TemplateColumn.DisplayTemplate>

</dxGrid:TemplateColumn>

<dxGrid:TextColumn
FieldName="Name"
Caption = "名字"
Width = "100" />

<dxGrid:NumberColumn
FieldName="UnitPrice"
Caption = "价格"
DisplayFormat="C0"/>

<dxGrid:DateColumn
FieldName="Date"
DisplayFormat="d"/>

<dxGrid:SwitchColumn
FieldName="Shipped" />

<dxGrid:TextColumn
FieldName="Name"
Caption = "Product" />

<dxGrid:TextColumn
FieldName="Name"
Caption = "Product" />

<dxGrid:TextColumn
FieldName="Name"
Caption = "Product" />

<dxGrid:TextColumn
FieldName="Name"
Caption = "Product" />

<dxGrid:TextColumn
FieldName="Name"
Caption = "Product" />

<dxGrid:TextColumn
FieldName="Name"
Caption = "Product" />

 

</dxGrid:GridControl.Columns>

<dxGrid:GridControl.LeftSwipeButtons>

<dxGrid:SwipeButtonInfo
ButtonName="LeftButton"
Caption="打印"
BackgroundColor="Green"
Width="150"/>

</dxGrid:GridControl.LeftSwipeButtons>

</dxGrid:GridControl>

特殊说明:如果直接使用绑定的文本则使用 Value关键字,绑定对象则可以直接使用Value.XXX

后端.cs代码绑定事件

void OnSwipeButtonShowing(object sender, DevExpress.Mobile.DataGrid.SwipeButtonShowingEventArgs e)

{

if ((!(Boolean)grid.GetCellValue(e.RowHandle, "Shipped"))

&& (e.ButtonInfo.ButtonName == "RightButton"))

{

e.IsVisible = false;

}

}

 

void OnSwipeButtonClick(object sender, DevExpress.Mobile.DataGrid.SwipeButtonEventArgs e)

{

if (e.ButtonInfo.ButtonName == "LeftButton")

{

string orderDate = (string)grid.GetCellValue(e.RowHandle, " Name");

string orderDateDay = orderDate;

DisplayAlert("Alert from " + e.ButtonInfo.ButtonName, "Day: " + orderDateDay, "OK");

}

if (e.ButtonInfo.ButtonName == "RightButton")

{

grid.DeleteRow(e.RowHandle);

}

}

Xamarin devexpress datagrid 样式的更多相关文章

  1. WPF DataGrid 样式设置

    隔行换色,鼠标单击,悬浮样式都有,其具体效果如图 1 所示. 图 1 WPF DataGrid 样式设置效果图 其中: 界面设计代码下所示 ? + 查看代码 1 2 3 4 5 6 7 8 9 10 ...

  2. DevExpress皮肤样式

    [时间] 2016-02-15 11:41:11 天气晴 没有雾霾难得的好天气!!! [工具] (1)Visual Studio 2015 (2)DevExpress15.2.3 [感言] 一直以来都 ...

  3. WPF DataGrid 样式分享

    原文:WPF DataGrid 样式分享 隔行换色,鼠标单击,悬浮样式都有 先看效果: 代码: <DataGrid AutoGenerateColumns="False" N ...

  4. Xamarin devexpress Grid

    Devexpress 提供了datagrid 控件对于xamarin 进行支持.整个世界美好了,已经无法用语言来形容一个 被列表控件折磨的要死的人看到熟悉的图标时候的激动了.还有一点引用官网的原话: ...

  5. Xamarin.Forms DataGrid

    控件出处 https://components.xamarin.com/ https://components.xamarin.com/gettingstarted/ZumeroDataGrid/tr ...

  6. WPF随手小记之二 ——改变DataGrid样式

    大部分时候我们并不需要手动改变DataGrid的样式,因为用默认的其实也看得过去,而且在DataGrid中的数据也远比外观重要. 但总有时候,我们需要做点必要的UI修改来使DataGrid更美观. 一 ...

  7. Xamarin.Forms之样式

    使用XAML样式设置Xamarin.Forms应用的样式Xamarin.Forms应用程序的样式传统上是通过使用Style类将一组属性值分组到一个对象中来完成的,然后可以将其应用于多个视觉元素实例. ...

  8. wpf 收集的不错的datagrid样式

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x ...

  9. DataGrid样式

    1.自定义列(DataGridTemplateColumn) <DataGridTemplateColumn Width="130"> <DataGridTemp ...

随机推荐

  1. Android中自定义Activity和Dialog的位置大小背景和透明度等

    1.自定义Activity显示样式 先在res/values下建colors.xml文件,写入: view plainprint? 1. <?xml version="1.0" ...

  2. QT5: QApplication, no such file or directory

    In QT5, when I use this: #include<QApplication>, QT tells :no such file or directory, even tho ...

  3. [Redux] Reducer Composition with Arrays

    In the previous lesson we created a reducer that can handle two actions, adding a new to-do, and tog ...

  4. Cocos2dx 多线程

    多-threaded负荷plist特征.获取知识的必要性: 1.多线程开启:pthread 2.怎样在线程中载入plist 一.多线程开启 当我们想在程序中开多线程中.第一想到的是cocos2d-x有 ...

  5. android 接听和挂断实现方式

    参考:android 来电接听和挂断 支持目前所有版本 注意:android2.3版本及以上不支持下面的自动接听方法. (会抛异常:java.lang.SecurityException: Neith ...

  6. 秒味课堂Angular js笔记------指令

    1.属性指令 angularjs样式相关指令: ng-class ng-style ng-href ng-src ng-attr-(suffix) ng-bind ng-cloak  没解析完之前标签 ...

  7. Dreamweaver管理Svn控制器内容

    一直以来很多人使用Dreamweaver来写css和xhtml.同时如果是应用于一个多人开发的项目的时候大家会使用svn或cvs来做版本控制的工作.但是可惜的是没有听说 Dreamweaver可以与版 ...

  8. iptables 下开放ftp

    这两天在给客户安装服务器时也顺便给他们使用iptables,不用不知道,一用才发现iptables还有很多东西可以学的,比如开放ftp.iptables 的filter表的INPUT链的默认策略设为了 ...

  9. 认识html标签

    让我们通过一个网页的学习,来对html标签有一个初步理解. 平常大家说的上网就是浏览各种各式各样的网页,这些网页都是由html标签组成的. 下面就是一个简单的网页.效果图如下: 我们来分析一下,这个网 ...

  10. WebBasic-表单

    用来提交数据 <form></form> 属性:action:提交的url  method:表单数据提交的方式  enctype:表单数据的编码方式 表单控件 --input元 ...