Skip to content

Commit 8f5a889

Browse files
committed
column chooser example added
1 parent c4dc3bf commit 8f5a889

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2611
-0
lines changed

CS/ColumnChooser/CS/App.xaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3+
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
4+
xmlns:local="clr-namespace:ColumnChooserExample"
5+
x:Class= "ColumnChooserExample.App"
6+
windows:Application.ImageDirectory="Assets">
7+
<Application.Resources>
8+
<Color x:Key="Primary">#6750A4</Color>
9+
<Color x:Key="Popup_Background_Light">#F3EDF7</Color>
10+
<Color x:Key="Popup_Background_Dark">#2B2831</Color>
11+
<Color x:Key="Gray50">#F2F2F7</Color>
12+
<Color x:Key="Gray100">#E1E1E1</Color>
13+
<Color x:Key="Gray200">#C8C8C8</Color>
14+
<Color x:Key="Gray300">#ACACAC</Color>
15+
<Color x:Key="Gray400">#919191</Color>
16+
<Color x:Key="Gray500">#6E6E6E</Color>
17+
<Color x:Key="Gray600">#404040</Color>
18+
<Color x:Key="Gray900">#212121</Color>
19+
<Color x:Key="Gray950">#141414</Color>
20+
<Color x:Key="NormalText">#55575c</Color>
21+
<Color x:Key="NormalHeaderText">#55575c</Color>
22+
<Color x:Key="NormalLightText">#959aa0</Color>
23+
<Color x:Key="TitleTextColor">White</Color>
24+
<Color x:Key="NormalBackgroundColor">White</Color>
25+
<Style TargetType="NavigationPage">
26+
<Setter Property="BarBackgroundColor" Value="{StaticResource Primary}" />
27+
<Setter Property="BarTextColor" Value="White" />
28+
</Style>
29+
30+
<Style TargetType="Shell" ApplyToDerivedTypes="True">
31+
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
32+
<Setter Property="Shell.TitleColor" Value="White" />
33+
</Style>
34+
</Application.Resources>
35+
</Application>

CS/ColumnChooser/CS/App.xaml.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace ColumnChooserExample {
2+
public partial class App : Application {
3+
public App() {
4+
InitializeComponent();
5+
6+
MainPage = new AppShell();
7+
}
8+
}
9+
}

CS/ColumnChooser/CS/AppShell.xaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="ColumnChooserExample.AppShell"
5+
xmlns:local="clr-namespace:ColumnChooserExample"
6+
Title="AppShell">
7+
<ShellContent
8+
Title="Active Sessions"
9+
ContentTemplate="{DataTemplate local:MainPage}"
10+
Route="MainPage" />
11+
</Shell>

CS/ColumnChooser/CS/AppShell.xaml.cs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace ColumnChooserExample;
2+
3+
public partial class AppShell : Shell {
4+
public AppShell()
5+
{
6+
InitializeComponent();
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net7.0-android;net7.0-ios</TargetFrameworks>
5+
<OutputType>Exe</OutputType>
6+
<UseMaui>true</UseMaui>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<SingleProject>true</SingleProject>
9+
<RootNamespace>ColumnChooserExample</RootNamespace>
10+
11+
<!-- Display name -->
12+
<ApplicationTitle>Column Chooser</ApplicationTitle>
13+
14+
<!-- App Identifier -->
15+
<ApplicationId>com.companyname.ColumnChooserExample</ApplicationId>
16+
<ApplicationIdGuid>98692B64-000A-4A04-8976-1F26386DC992</ApplicationIdGuid>
17+
<!-- Versions -->
18+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
19+
<ApplicationVersion>1</ApplicationVersion>
20+
21+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
22+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
23+
<UseInterpreter Condition="$(TargetFramework.Contains('-ios')) AND '$(Configuration)' == 'Release'">True</UseInterpreter>
24+
</PropertyGroup>
25+
<ItemGroup>
26+
<!-- App Icon -->
27+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#6750A4" />
28+
29+
<!-- Splash Screen -->
30+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#6750A4" BaseSize="128,128" />
31+
32+
<!-- Images -->
33+
<MauiImage Include="Resources\Images\*" />
34+
35+
<!-- Custom Fonts -->
36+
<MauiFont Include="Resources\Fonts\*" />
37+
</ItemGroup>
38+
39+
40+
<ItemGroup>
41+
<PackageReference Include="DevExpress.Maui.CollectionView" Version="22.2.3" />
42+
<PackageReference Include="DevExpress.Maui.Core" Version="22.2.3" />
43+
<PackageReference Include="DevExpress.Maui.DataGrid" Version="22.2.3" />
44+
<TrimmableAssembly Include="DevExpress.Data.v22.2" />
45+
</ItemGroup>
46+
47+
48+
<ItemGroup>
49+
<MauiXaml Update="AppShell.xaml">
50+
<Generator>MSBuild:Compile</Generator>
51+
</MauiXaml>
52+
</ItemGroup>
53+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33122.133
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColumnChooserExample", "ColumnChooserExample.csproj", "{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{BE3FF191-4AA7-4FB0-9FC8-17AA943F3DFF}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {C2DD4574-E3E8-484E-AC36-65572A57A33E}
26+
EndGlobalSection
27+
EndGlobal
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Welcome to DevExpress Components for .NET MAUI! Here are a few tips to help you get started with your new application.
2+
3+
DevExpress NuGet Feed
4+
---------------------
5+
6+
DevExpress Components for .NET MAUI are free-of-charge. To learn more about our free offer and reserve your free copy,
7+
please visit the following webpage: https://www.devexpress.com/mobile-xamarin-maui-free/
8+
9+
IMPORTANT: You MUST register your personal NuGet package source for the solution to build correctly.
10+
After you reserved your free copy, you can use the following page to obtain a NuGet Feed URL: https://nuget.devexpress.com/
11+
12+
If you are unfamiliar with NuGet packages, please review the following
13+
help topic (Install DevExpress Controls Using NuGet Packages): https://docs.devexpress.com/GeneralInformation/115912/
14+
15+
QuickStart Guide
16+
----------------
17+
18+
See the following topic to learn more about DevExpress Components for .NET MAUI: https://docs.devexpress.com/MAUI

CS/ColumnChooser/CS/MainPage.xaml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3+
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
4+
xmlns:dxcv="clr-namespace:DevExpress.Maui.CollectionView;assembly=DevExpress.Maui.CollectionView"
5+
xmlns:dxco="clr-namespace:DevExpress.Maui.Controls;assembly=DevExpress.Maui.Controls"
6+
xmlns:dxg="clr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid"
7+
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
8+
xmlns:local="clr-namespace:ColumnChooserExample"
9+
ios:Page.UseSafeArea="true"
10+
x:Class= "ColumnChooserExample.MainPage">
11+
<ContentPage.BindingContext>
12+
<local:MainViewModel/>
13+
</ContentPage.BindingContext>
14+
<ContentPage.ToolbarItems>
15+
<ToolbarItem IconImageSource="columnchooser" Clicked="ShowColumnChooserClick"/>
16+
</ContentPage.ToolbarItems>
17+
<Grid>
18+
<dxg:DataGridView x:Name="dataGrid" ItemsSource="{Binding ActiveUsers}" AutoGenerateColumnsMode="None" VerticalLineThickness="0">
19+
<dxg:TemplateColumn FieldName="Country" MinWidth="150">
20+
<dxg:TemplateColumn.DisplayTemplate>
21+
<DataTemplate>
22+
<Grid ColumnDefinitions="Auto, *" RowDefinitions="*,*" Padding="10">
23+
<Image Source="{Binding Item.ImagePath}" Margin="0,0,10,0" Grid.RowSpan="2" HeightRequest="18"/>
24+
<Label Text="{Binding Item.Country}" TextColor="{AppThemeBinding Light={StaticResource Gray900}, Dark=White}" FontAttributes="Bold" Grid.Column="1"/>
25+
<Label Text="{Binding Item.City}" TextColor="{AppThemeBinding Light={StaticResource Gray500}, Dark={StaticResource Gray300}}" Grid.Column="1" Grid.Row="1"/>
26+
</Grid>
27+
</DataTemplate>
28+
</dxg:TemplateColumn.DisplayTemplate>
29+
</dxg:TemplateColumn>
30+
<dxg:TextColumn FieldName="CameFrom" Caption="Souce" MinWidth="120" FontSize="12"/>
31+
<dxg:TextColumn FieldName="TimeOnSite" Caption="Duration" MinWidth="120" FontSize="12" IsVisible="False"/>
32+
<dxg:TextColumn FieldName="LastPage" MinWidth="130" FontSize="12" IsVisible="False"/>
33+
<dxg:TextColumn FieldName="IsReturningUser" Caption="Returning" FontSize="12" MinWidth="130"/>
34+
</dxg:DataGridView>
35+
<dxco:DXPopup x:Name="columnChooserPopup" BackgroundColor="{AppThemeBinding Light={StaticResource Popup_Background_Light}, Dark={StaticResource Popup_Background_Dark}}" HorizontalOptions="Fill" Margin="30,0,30,0" CornerRadius="6">
36+
<dxcv:DXCollectionView Margin="20"
37+
ItemSpacing="4"
38+
ItemsSource="{Binding Source={Reference dataGrid}, Path=Columns}"
39+
HorizontalOptions="Fill"
40+
ReduceSizeToContent="true">
41+
<dxcv:DXCollectionView.ItemTemplate>
42+
<DataTemplate>
43+
<Grid ColumnDefinitions="*,Auto">
44+
<Border Background="{AppThemeBinding Light={StaticResource Popup_Background_Light}, Dark={StaticResource Popup_Background_Dark}}" HeightRequest="56">
45+
<dxe:CheckEdit IsChecked="{Binding IsVisible}" Label="{Binding ActualCaption}" CheckBoxPosition="End" Margin="16,8,10,8"/>
46+
</Border>
47+
</Grid>
48+
</DataTemplate>
49+
</dxcv:DXCollectionView.ItemTemplate>
50+
</dxcv:DXCollectionView>
51+
</dxco:DXPopup>
52+
</Grid>
53+
</ContentPage>

CS/ColumnChooser/CS/MainPage.xaml.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace ColumnChooserExample {
2+
public partial class MainPage : ContentPage {
3+
public MainPage() {
4+
InitializeComponent();
5+
}
6+
7+
private void ShowColumnChooserClick(object sender, EventArgs e) {
8+
columnChooserPopup.IsOpen = true;
9+
}
10+
}
11+
}

CS/ColumnChooser/CS/MainViewModel.cs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace ColumnChooserExample {
9+
public class MainViewModel {
10+
public ObservableCollection<SiteUser> ActiveUsers {
11+
get;
12+
set;
13+
}
14+
public MainViewModel() {
15+
ActiveUsers = Data.CreateSiteUsers();
16+
}
17+
}
18+
19+
public class SiteUser {
20+
public int Id { get; set; }
21+
public string Country { get; set; }
22+
public string City { get; set; }
23+
public string LastPage { get; set; }
24+
public string CameFrom { get; set; }
25+
public int Pageviews { get; set; }
26+
public TimeSpan TimeOnSite { get; set; }
27+
public bool IsReturningUser { get; set; }
28+
string imagePath;
29+
public string ImagePath { get {
30+
if (imagePath == null && Country != null)
31+
imagePath = Country.ToLower().Replace(" ","");;
32+
return imagePath;
33+
} }
34+
}
35+
36+
public static class Data {
37+
public static ObservableCollection<SiteUser> CreateSiteUsers() {
38+
ObservableCollection<SiteUser> siteUsers = new ObservableCollection<SiteUser> {
39+
new SiteUser { Id = 0, Country = "Brazil", City = "Sao Paulo", CameFrom = "google", LastPage = "Home", Pageviews = 1, TimeOnSite = new TimeSpan(0, 0, 46), IsReturningUser = false },
40+
new SiteUser { Id = 1, Country = "USA", City = "New York", CameFrom = "facebook", LastPage = "Buy", Pageviews = 10, TimeOnSite = new TimeSpan(0, 10, 12), IsReturningUser = true },
41+
new SiteUser { Id = 2, Country = "France", City = "Marseille", CameFrom = "twitter", LastPage = "About Us", Pageviews = 2, TimeOnSite = new TimeSpan(0, 3, 2), IsReturningUser = true },
42+
new SiteUser { Id = 3, Country = "Germany", City = "Berlin", CameFrom = "google", LastPage = ".NET MAUI Components", Pageviews = 4, TimeOnSite = new TimeSpan(0, 5, 55), IsReturningUser = false },
43+
new SiteUser { Id = 4, Country = "India", City = "Chennai", CameFrom = "bing", LastPage = "Home", Pageviews = 4, TimeOnSite = new TimeSpan(0, 8, 9), IsReturningUser = true },
44+
new SiteUser { Id = 5, Country = "Canada", City = "Ottawa", CameFrom = "google", LastPage = ".NET MAUI Documentation", Pageviews = 5, TimeOnSite = new TimeSpan(0, 9, 11), IsReturningUser = true },
45+
new SiteUser { Id = 6, Country = "Sweden", City = "Stockholm", CameFrom = "github", LastPage = "Universal", Pageviews = 12, TimeOnSite = new TimeSpan(0, 20, 12), IsReturningUser = false },
46+
new SiteUser { Id = 7, Country = "Poland", City = "Krakow", CameFrom = "google", LastPage = "Renew", Pageviews = 4, TimeOnSite = new TimeSpan(0, 2, 2), IsReturningUser = true },
47+
new SiteUser { Id = 8, Country = "USA", City = "Los Angeles", CameFrom = "github", LastPage = "Blogs", Pageviews = 7, TimeOnSite = new TimeSpan(0, 9, 44), IsReturningUser = true },
48+
new SiteUser { Id = 9, Country = "Germany", City = "Frankfurt", CameFrom = "twitter", LastPage = "Technical Support", Pageviews = 4, TimeOnSite = new TimeSpan(0, 8, 40), IsReturningUser = true },
49+
new SiteUser { Id = 10, Country = "Argentina", City = "Salta", CameFrom = "google", LastPage = "Demos", Pageviews = 9, TimeOnSite = new TimeSpan(0, 30, 20), IsReturningUser = false },
50+
new SiteUser { Id = 11, Country = "France", City = "Paris", CameFrom = "bing", LastPage = "Buy", Pageviews = 20, TimeOnSite = new TimeSpan(0, 22, 20), IsReturningUser = true },
51+
new SiteUser { Id = 12, Country = "Japan", City = "Osaka", CameFrom = "github", LastPage = ".NET MAUI Components", Pageviews = 2, TimeOnSite = new TimeSpan(0, 1, 16), IsReturningUser = true },
52+
new SiteUser { Id = 13, Country = "Belgium", City = "Brussels", CameFrom = "google", LastPage = "Support", Pageviews = 3, TimeOnSite = new TimeSpan(0, 4, 11), IsReturningUser = true },
53+
new SiteUser { Id = 14, Country = "India", City = "New Delhi", CameFrom = "google", LastPage = "Examples", Pageviews = 5, TimeOnSite = new TimeSpan(0, 8, 1), IsReturningUser = true }
54+
};
55+
return siteUsers;
56+
}
57+
}
58+
}

CS/ColumnChooser/CS/MauiProgram.cs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using DevExpress.Maui;
2+
using Microsoft.Maui;
3+
using Microsoft.Maui.Controls.Compatibility;
4+
using Microsoft.Maui.Controls.Compatibility.Hosting;
5+
using Microsoft.Maui.Controls.Hosting;
6+
using Microsoft.Maui.Hosting;
7+
8+
namespace ColumnChooserExample {
9+
public static class MauiProgram {
10+
public static MauiApp CreateMauiApp() {
11+
var builder = MauiApp.CreateBuilder();
12+
builder
13+
.UseMauiApp<App>()
14+
.UseDevExpress(useLocalization: true)
15+
.ConfigureFonts(fonts =>
16+
{
17+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
18+
fonts.AddFont("univia-pro-regular.ttf", "Univia-Pro");
19+
fonts.AddFont("roboto-bold.ttf", "Roboto-Bold");
20+
fonts.AddFont("roboto-regular.ttf", "Roboto");
21+
});
22+
23+
return builder.Build();
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
4+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round"></application>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace ColumnChooserExample {
6+
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
7+
public class MainActivity : MauiAppCompatActivity {
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace ColumnChooserExample {
5+
[Application]
6+
public class MainApplication : MauiApplication {
7+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
8+
: base(handle, ownership) {
9+
}
10+
11+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#512BD4</color>
4+
<color name="colorPrimaryDark">#6750A4</color>
5+
<color name="colorAccent">#2B0B98</color>
6+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<resources>
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<item name="colorPrimary">@color/colorPrimary</item>
6+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
7+
<item name="colorAccent">@color/colorAccent</item>
8+
</style>
9+
<style name="AppTheme.NoActionBar">
10+
<item name="windowActionBar">false</item>
11+
<item name="windowNoTitle">true</item>
12+
</style>
13+
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
14+
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
15+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Foundation;
2+
3+
namespace ColumnChooserExample {
4+
[Register("AppDelegate")]
5+
public class AppDelegate : MauiUIApplicationDelegate {
6+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
7+
}
8+
}

0 commit comments

Comments
 (0)