Skip to content

Commit 8ddec8e

Browse files
committed
Release
1 parent 8b7971d commit 8ddec8e

File tree

2,452 files changed

+82540
-905
lines changed

Some content is hidden

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

2,452 files changed

+82540
-905
lines changed

BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/BionicCode.Controls.Net.Core.Wpf.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<ApplicationIcon>logo.ico</ApplicationIcon>
77
</PropertyGroup>
88

9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<DocumentationFile>D:\-Programming-\C#\GitOpenSourceRepository\BionicCode.Net\BionicCode.Net\BionicCode.Controls.Net.Core.Wpf\BionicCode.Controls.Net.Core.Wpf.xml</DocumentationFile>
11+
</PropertyGroup>
12+
913
<ItemGroup>
1014
<Page Update="Themes\Generic.xaml">
1115
<SubType>Designer</SubType>

BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/BionicCode.Controls.Net.Core.Wpf.xml

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/ClosableTabControl.cs renamed to BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/Control/ClosableTabControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Windows.Controls;
44
using System.Windows.Input;
55

6-
namespace BionicCode.Controls.Net.Core.Wpf
6+
namespace BionicCode.Controls.Net.Core.Wpf.Control
77
{
88
/// <summary>
99
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.

BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/HighlightRichTextBox.cs renamed to BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/Control/HighlightRichTextBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#endregion
1414

15-
namespace BionicCode.Controls.Net.Core.Wpf
15+
namespace BionicCode.Controls.Net.Core.Wpf.Control
1616
{
1717
/// <summary>
1818
/// Implement this interface to apply a custom highlight style for more complex scenarios e.g., code editors.

BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/NormalizingNumericTextBox.cs renamed to BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/Control/NormalizingNumericTextBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using System.Windows.Data;
99
using System.Windows.Input;
1010

11-
namespace BionicCode.Controls.Net.Core.Wpf
11+
namespace BionicCode.Controls.Net.Core.Wpf.Control
1212
{
1313
/// <summary>
1414
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using System.Collections.Specialized;
2+
using System.Windows;
3+
using System.Windows.Controls;
4+
using System.Windows.Media;
5+
6+
namespace BionicCode.Controls.Net.Core.Wpf.Control
7+
{
8+
public enum ItemsUpdatingScrollMode
9+
{
10+
Default = 0,
11+
KeepItemsInView, // Adjusts the scroll offset to keep the first visible item in the viewport when items are added to the ItemsSource.
12+
KeepLastItemInView, // Adjusts the scroll offset to keep the last visible item in the viewport when items are added to the ItemsSource.
13+
KeepScrollOffset // Maintains the scroll offset relative to the beginning of the list, forcing items in the viewport to move down when items are added to the ItemsSource.
14+
}
15+
16+
public class ScrollModeListBox : System.Windows.Controls.ListBox
17+
{
18+
public static readonly DependencyProperty ItemsUpdatingScrollModeProperty = DependencyProperty.Register(
19+
"ItemsUpdatingScrollMode",
20+
typeof(ItemsUpdatingScrollMode),
21+
typeof(ScrollModeListBox),
22+
new PropertyMetadata(default(ItemsUpdatingScrollMode)));
23+
24+
public ItemsUpdatingScrollMode ItemsUpdatingScrollMode
25+
{
26+
get => (ItemsUpdatingScrollMode) GetValue(ScrollModeListBox.ItemsUpdatingScrollModeProperty);
27+
set => SetValue(ScrollModeListBox.ItemsUpdatingScrollModeProperty, value);
28+
}
29+
30+
private ScrollViewer ScrollViewer { get; set; }
31+
32+
public ScrollModeListBox()
33+
{
34+
this.ItemsUpdatingScrollMode = ItemsUpdatingScrollMode.KeepScrollOffset;
35+
}
36+
37+
#region Overrides of FrameworkElement
38+
39+
/// <inheritdoc />
40+
public override void OnApplyTemplate()
41+
{
42+
base.OnApplyTemplate();
43+
if (TryFindVisualChildElement(this, out ScrollViewer scrollViewer))
44+
{
45+
this.ScrollViewer = scrollViewer;
46+
}
47+
}
48+
49+
#endregion
50+
51+
#region Overrides of ListView
52+
53+
/// <inheritdoc />
54+
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
55+
{
56+
base.OnItemsChanged(e);
57+
if (this.ScrollViewer == null)
58+
{
59+
return;
60+
}
61+
62+
double verticalOffset;
63+
switch (this.ItemsUpdatingScrollMode)
64+
{
65+
case ItemsUpdatingScrollMode.Default:
66+
case ItemsUpdatingScrollMode.KeepScrollOffset:
67+
return;
68+
case ItemsUpdatingScrollMode.KeepItemsInView:
69+
switch (e.Action)
70+
{
71+
case NotifyCollectionChangedAction.Add when e.NewItems != null:
72+
73+
// Check if insert or add
74+
verticalOffset = e.NewStartingIndex < this.ScrollViewer.VerticalOffset
75+
? this.ScrollViewer.VerticalOffset + e.NewItems.Count
76+
: this.ScrollViewer.VerticalOffset;
77+
break;
78+
case NotifyCollectionChangedAction.Remove when e.OldItems != null:
79+
verticalOffset = this.ScrollViewer.VerticalOffset - e.OldItems.Count;
80+
break;
81+
default:
82+
verticalOffset = this.ScrollViewer.VerticalOffset;
83+
break;
84+
}
85+
86+
break;
87+
case ItemsUpdatingScrollMode.KeepLastItemInView:
88+
verticalOffset = this.ScrollViewer.ScrollableHeight;
89+
break;
90+
default:
91+
return;
92+
}
93+
94+
this.ScrollViewer?.ScrollToVerticalOffset(verticalOffset);
95+
}
96+
97+
98+
#endregion
99+
100+
public bool TryFindVisualChildElement<TChild>(DependencyObject parent, out TChild childElement)
101+
where TChild : FrameworkElement
102+
{
103+
childElement = null;
104+
if (parent == null)
105+
{
106+
return false;
107+
}
108+
109+
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
110+
{
111+
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
112+
if (child is TChild resultElement)
113+
{
114+
childElement = resultElement;
115+
return true;
116+
}
117+
118+
if (TryFindVisualChildElement(child, out childElement))
119+
{
120+
return true;
121+
}
122+
}
123+
124+
return false;
125+
}
126+
}
127+
}

BionicCode.Net/BionicCode.Controls.Net.Core.Wpf/Themes/Generic.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ResourceDictionary
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:wpf="clr-namespace:BionicCode.Controls.Net.Core.Wpf">
4+
xmlns:wpf="clr-namespace:BionicCode.Controls.Net.Core.Wpf.Control">
55
<Style TargetType="wpf:NormalizingNumericTextBox">
66
<Setter Property="BorderThickness" Value="1" />
77
<Setter Property="BorderBrush" Value="DarkGray" />

0 commit comments

Comments
 (0)