Skip to content

Commit 433c256

Browse files
Merge pull request #1 from ShobikaPalani/master
How to define summary rows using AttachedProperty
2 parents b51ad10 + 1784708 commit 433c256

Some content is hidden

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

46 files changed

+17929
-0
lines changed

UWP/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application
2+
x:Class="SfDataGridDemo.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:SfDataGridDemo"
6+
RequestedTheme="Light">
7+
8+
</Application>

UWP/App.xaml.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.ApplicationModel;
7+
using Windows.ApplicationModel.Activation;
8+
using Windows.Foundation;
9+
using Windows.Foundation.Collections;
10+
using Windows.UI.Xaml;
11+
using Windows.UI.Xaml.Controls;
12+
using Windows.UI.Xaml.Controls.Primitives;
13+
using Windows.UI.Xaml.Data;
14+
using Windows.UI.Xaml.Input;
15+
using Windows.UI.Xaml.Media;
16+
using Windows.UI.Xaml.Navigation;
17+
18+
namespace SfDataGridDemo
19+
{
20+
/// <summary>
21+
/// Provides application-specific behavior to supplement the default Application class.
22+
/// </summary>
23+
sealed partial class App : Application
24+
{
25+
/// <summary>
26+
/// Initializes the singleton application object. This is the first line of authored code
27+
/// executed, and as such is the logical equivalent of main() or WinMain().
28+
/// </summary>
29+
public App()
30+
{
31+
this.InitializeComponent();
32+
this.Suspending += OnSuspending;
33+
}
34+
35+
/// <summary>
36+
/// Invoked when the application is launched normally by the end user. Other entry points
37+
/// will be used such as when the application is launched to open a specific file.
38+
/// </summary>
39+
/// <param name="e">Details about the launch request and process.</param>
40+
protected override void OnLaunched(LaunchActivatedEventArgs e)
41+
{
42+
#if DEBUG
43+
if (System.Diagnostics.Debugger.IsAttached)
44+
{
45+
this.DebugSettings.EnableFrameRateCounter = true;
46+
}
47+
#endif
48+
Frame rootFrame = Window.Current.Content as Frame;
49+
50+
// Do not repeat app initialization when the Window already has content,
51+
// just ensure that the window is active
52+
if (rootFrame == null)
53+
{
54+
// Create a Frame to act as the navigation context and navigate to the first page
55+
rootFrame = new Frame();
56+
57+
rootFrame.NavigationFailed += OnNavigationFailed;
58+
59+
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
60+
{
61+
//TODO: Load state from previously suspended application
62+
}
63+
64+
// Place the frame in the current Window
65+
Window.Current.Content = rootFrame;
66+
}
67+
68+
if (e.PrelaunchActivated == false)
69+
{
70+
if (rootFrame.Content == null)
71+
{
72+
// When the navigation stack isn't restored navigate to the first page,
73+
// configuring the new page by passing required information as a navigation
74+
// parameter
75+
rootFrame.Navigate(typeof(MainPage), e.Arguments);
76+
}
77+
// Ensure the current window is active
78+
Window.Current.Activate();
79+
}
80+
}
81+
82+
/// <summary>
83+
/// Invoked when Navigation to a certain page fails
84+
/// </summary>
85+
/// <param name="sender">The Frame which failed navigation</param>
86+
/// <param name="e">Details about the navigation failure</param>
87+
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
88+
{
89+
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
90+
}
91+
92+
/// <summary>
93+
/// Invoked when application execution is being suspended. Application state is saved
94+
/// without knowing whether the application will be terminated or resumed with the contents
95+
/// of memory still intact.
96+
/// </summary>
97+
/// <param name="sender">The source of the suspend request.</param>
98+
/// <param name="e">Details about the suspend request.</param>
99+
private void OnSuspending(object sender, SuspendingEventArgs e)
100+
{
101+
var deferral = e.SuspendingOperation.GetDeferral();
102+
//TODO: Save application state and stop any background activity
103+
deferral.Complete();
104+
}
105+
}
106+
}
1.4 KB
Loading
7.52 KB
Loading
2.87 KB
Loading
1.61 KB
Loading
1.23 KB
Loading

UWP/Assets/StoreLogo.png

1.42 KB
Loading
3.13 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Syncfusion.UI.Xaml.Grid;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Windows.UI.Xaml;
8+
9+
namespace SfDataGridDemo
10+
{
11+
public class SfDataGridAttachedProperty
12+
{
13+
public static readonly DependencyProperty DynamicSummaryColumnsProperty = DependencyProperty.RegisterAttached(
14+
"DynamicSummaryColumns",
15+
typeof(List<GridSummaryColumn>),
16+
typeof(SfDataGridAttachedProperty)
17+
, new PropertyMetadata(null, OnDynamicSummaryColumnsChanged));
18+
19+
public static void SetDynamicSummaryColumns(UIElement element, List<GridSummaryColumn> value)
20+
{
21+
element.SetValue(DynamicSummaryColumnsProperty, value);
22+
}
23+
public static List<GridSummaryColumn> GetDynamicSummaryColumns(UIElement element)
24+
{
25+
return (List<GridSummaryColumn>)element.GetValue(DynamicSummaryColumnsProperty);
26+
}
27+
28+
private static void OnDynamicSummaryColumnsChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
29+
{
30+
31+
SfDataGrid grid = d as SfDataGrid;
32+
33+
if (grid.TableSummaryRows.Count() > 1)
34+
{
35+
grid.TableSummaryRows.Clear();
36+
}
37+
38+
GridTableSummaryRow gsr = new GridTableSummaryRow();
39+
gsr.ShowSummaryInRow = false;
40+
41+
var list = ((List<GridSummaryColumn>)args.NewValue);
42+
43+
foreach (var item in list)
44+
{
45+
gsr.SummaryColumns.Add(item);
46+
}
47+
48+
grid.TableSummaryRows.Add(gsr);
49+
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)