Skip to content

Commit 5ce8953

Browse files
committed
KB-20838 - Sample and README.md updated
1 parent ce709aa commit 5ce8953

File tree

5 files changed

+22
-30
lines changed

5 files changed

+22
-30
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# How to scroll vertically by less than a full row in a WPF DataGrid (SfDataGrid)
1+
# How to scroll vertically by less than a full row in a WPF DataGrid?
22

33

4-
In [WPF DataGrid](https://www.syncfusion.com/wpf-controls/datagrid) (SfDataGrid), vertical scrolling moves one full row at a time. You can modify this behavior to scroll by your preferred units by adjusting the vertical offset in the [ScrollChanged](https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.scrollviewer.scrollchanged?view=netframework-4.7.2) event.
4+
In [WPF DataGrid](https://www.syncfusion.com/wpf-controls/datagrid) (SfDataGrid), vertical scrolling by default advances one full row at a time. This behavior can be customized to scroll by specific units by adjusting the vertical offset within the `ScrollChanged` event.
55

6-
**Code snippet to scroll vertically by less than a full row:**
7-
8-
96
```csharp
107
sfDataGrid.Loaded += OnLoaded;
118

SfDataGrid_Demo/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
5151
{
5252
if (e.VerticalChange < 0)
5353
{
54-
// // Here customize based on your scenario
54+
//Here customize based on your scenario
5555
double newOffset = e.VerticalOffset + 12;
5656
this.sfDataGrid.GetVisualContainer().SetVerticalOffset(newOffset);
5757
}

SfDataGrid_Demo/Model/Model.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Linq;
5+
using System.Runtime.CompilerServices;
46
using System.Text;
57
using System.Threading.Tasks;
68

79
namespace SfDataGrid_Demo.Model
810
{
9-
public class OrderInfo
11+
public class OrderInfo : INotifyPropertyChanged
1012
{
1113
int orderID;
1214
string customerId;
1315
string country;
1416
string customerName;
1517
string shippingCity;
18+
public event PropertyChangedEventHandler PropertyChanged;
1619

1720
public int OrderID
1821
{
1922
get { return orderID; }
20-
set { orderID = value; }
23+
set { orderID = value; OnPropertyChanged("OrderID"); }
2124
}
2225

2326
public string CustomerID
2427
{
2528
get { return customerId; }
26-
set { customerId = value; }
29+
set { customerId = value; OnPropertyChanged("CustomerID"); }
2730
}
2831

2932
public string CustomerName
3033
{
3134
get { return customerName; }
32-
set { customerName = value; }
35+
set { customerName = value; OnPropertyChanged("CustomerName"); }
3336
}
3437

3538
public string Country
3639
{
3740
get { return country; }
38-
set { country = value; }
41+
set { country = value; OnPropertyChanged("Country"); }
3942
}
4043

4144
public string ShipCity
4245
{
4346
get { return shippingCity; }
44-
set { shippingCity = value; }
47+
set { shippingCity = value; OnPropertyChanged("ShipCity"); }
4548
}
4649

4750
public OrderInfo(int orderId, string customerName, string country, string customerId, string shipCity)
@@ -52,5 +55,12 @@ public OrderInfo(int orderId, string customerName, string country, string custom
5255
this.CustomerID = customerId;
5356
this.ShipCity = shipCity;
5457
}
58+
59+
60+
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
61+
{
62+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
63+
}
64+
5565
}
5666
}

SfDataGrid_Demo/SfDataGrid_Demo.csproj

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,9 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38-
<Reference Include="Syncfusion.Data.WPF, Version=30.1462.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
39-
<SpecificVersion>False</SpecificVersion>
40-
<HintPath>..\..\..\..\..\..\Dlls\latest WPF_Licensed Dlls\4.6.2\Syncfusion.Data.WPF.dll</HintPath>
41-
</Reference>
42-
<Reference Include="Syncfusion.SfGrid.WPF, Version=30.1462.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
43-
<SpecificVersion>False</SpecificVersion>
44-
<HintPath>..\..\..\..\..\..\Dlls\latest WPF_Licensed Dlls\4.6.2\Syncfusion.SfGrid.WPF.dll</HintPath>
45-
</Reference>
46-
<Reference Include="Syncfusion.Shared.WPF, Version=30.1462.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
47-
<SpecificVersion>False</SpecificVersion>
48-
<HintPath>..\..\..\..\..\..\Dlls\latest WPF_Licensed Dlls\4.6.2\Syncfusion.Shared.WPF.dll</HintPath>
49-
</Reference>
38+
<Reference Include="Syncfusion.Data.WPF" />
39+
<Reference Include="Syncfusion.SfGrid.WPF" />
40+
<Reference Include="Syncfusion.Shared.WPF" />
5041
<Reference Include="System" />
5142
<Reference Include="System.Data" />
5243
<Reference Include="System.Xml" />

SfDataGrid_Demo/SfDataGrid_Demo.csproj.user

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)