-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from fabulous-dev/items-control
ItemsControl Widget
- Loading branch information
Showing
11 changed files
with
147 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Gallery | ||
|
||
open System.Diagnostics | ||
open Avalonia | ||
open Avalonia.Controls.Primitives | ||
open Avalonia.Layout | ||
open Avalonia.Media | ||
open Fabulous.Avalonia | ||
open Fabulous | ||
open System.Collections.ObjectModel | ||
|
||
open type Fabulous.Avalonia.View | ||
|
||
module ItemsControlPage = | ||
type Crockery = { Title: string; Number: int } | ||
|
||
let items = [ for i in 1..1000 -> { Title = "dinner plate"; Number = i } ] | ||
|
||
let view () = | ||
|
||
VStack() { | ||
TextBlock("List of crockery:") | ||
|
||
ItemsControl( | ||
items, | ||
fun item -> | ||
HStack() { | ||
TextBlock(item.Title) | ||
TextBlock(item.Number.ToString()) | ||
} | ||
) | ||
.itemsPanel(VirtualizingStackPanel()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/Fabulous.Avalonia/Views/Panels/VirtualizingStackPanel.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
namespace Fabulous.Avalonia | ||
|
||
open System.Runtime.CompilerServices | ||
open Avalonia.Controls | ||
open Avalonia.Interactivity | ||
open Fabulous | ||
open Fabulous.StackAllocatedCollections.StackList | ||
|
||
type IFabVirtualizingStackPanel = | ||
inherit IFabVirtualizingPanel | ||
|
||
module VirtualizingStackPanel = | ||
let WidgetKey = Widgets.register<VirtualizingStackPanel>() | ||
|
||
let Orientation = | ||
Attributes.defineAvaloniaPropertyWithEquality VirtualizingStackPanel.OrientationProperty | ||
|
||
let AreHorizontalSnapPointsRegular = | ||
Attributes.defineAvaloniaPropertyWithEquality VirtualizingStackPanel.AreHorizontalSnapPointsRegularProperty | ||
|
||
let AreVerticalSnapPointsRegular = | ||
Attributes.defineAvaloniaPropertyWithEquality VirtualizingStackPanel.AreVerticalSnapPointsRegularProperty | ||
|
||
let HorizontalSnapPointsChanged = | ||
Attributes.defineEvent "VirtualizingStackPanel_HorizontalSnapPointsChanged" (fun target -> | ||
(target :?> VirtualizingStackPanel) | ||
.HorizontalSnapPointsChanged) | ||
|
||
let VerticalSnapPointsChanged = | ||
Attributes.defineEvent "VirtualizingStackPanel_VerticalSnapPointsChanged" (fun target -> | ||
(target :?> VirtualizingStackPanel) | ||
.VerticalSnapPointsChanged) | ||
|
||
[<AutoOpen>] | ||
module VirtualizingStackPanelBuilders = | ||
type Fabulous.Avalonia.View with | ||
|
||
/// <summary>Creates a VirtualizingStackPanel widget.</summary> | ||
static member VirtualizingStackPanel() = | ||
WidgetBuilder<'msg, IFabVirtualizingStackPanel>(VirtualizingStackPanel.WidgetKey, AttributesBundle(StackList.empty(), ValueNone, ValueNone)) | ||
|
||
type VirtualizingStackPanelModifiers = | ||
/// <summary>Sets the AreHorizontalSnapPointsRegular property.</summary> | ||
/// <param name="this">Current widget.</param> | ||
/// <param name="value">The AreHorizontalSnapPointsRegular value.</param> | ||
[<Extension>] | ||
static member inline areHorizontalSnapPointsRegular(this: WidgetBuilder<'msg, #IFabVirtualizingStackPanel>, value: bool) = | ||
this.AddScalar(VirtualizingStackPanel.AreHorizontalSnapPointsRegular.WithValue(value)) | ||
|
||
/// <summary>Sets the AreVerticalSnapPointsRegular property.</summary> | ||
/// <param name="this">Current widget.</param> | ||
/// <param name="value">The AreVerticalSnapPointsRegular value.</param> | ||
[<Extension>] | ||
static member inline areVerticalSnapPointsRegular(this: WidgetBuilder<'msg, #IFabVirtualizingStackPanel>, value: bool) = | ||
this.AddScalar(VirtualizingStackPanel.AreVerticalSnapPointsRegular.WithValue(value)) | ||
|
||
/// <summary>Listens to the StackPanel HorizontalSnapPointsChanged event.</summary> | ||
/// <param name="this">Current widget.</param> | ||
/// <param name="fn">Raised when the HorizontalSnapPointsChanged event fires.</param> | ||
[<Extension>] | ||
static member inline onHorizontalSnapPointsChanged(this: WidgetBuilder<'msg, #IFabVirtualizingStackPanel>, fn: RoutedEventArgs -> 'msg) = | ||
this.AddScalar(VirtualizingStackPanel.HorizontalSnapPointsChanged.WithValue(fn)) | ||
|
||
/// <summary>Listens to the StackPanel VerticalSnapPointsChanged event.</summary> | ||
/// <param name="this">Current widget.</param> | ||
/// <param name="fn">Raised when the VerticalSnapPointsChanged event fires.</param> | ||
[<Extension>] | ||
static member inline onVerticalSnapPointsChanged(this: WidgetBuilder<'msg, #IFabVirtualizingStackPanel>, fn: RoutedEventArgs -> 'msg) = | ||
this.AddScalar(VirtualizingStackPanel.VerticalSnapPointsChanged.WithValue(fn)) | ||
|
||
/// <summary>Link a ViewRef to access the direct VirtualizingStackPanel control instance.</summary> | ||
/// <param name="this">Current widget.</param> | ||
/// <param name="value">The ViewRef instance that will receive access to the underlying control.</param> | ||
[<Extension>] | ||
static member inline reference(this: WidgetBuilder<'msg, IFabVirtualizingStackPanel>, value: ViewRef<VirtualizingStackPanel>) = | ||
this.AddScalar(ViewRefAttributes.ViewRef.WithValue(value.Unbox)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace Fabulous.Avalonia | ||
|
||
type IFabVirtualizingPanel = | ||
inherit IFabPanel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters