Skip to content

Commit 527bf92

Browse files
committed
Fixing bulletspacing
1 parent be9700d commit 527bf92

4 files changed

Lines changed: 58 additions & 1 deletion

File tree

components/MarkdownTextBlock/samples/MarkdownTextBlockCustomThemeSampleBase.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public abstract partial class MarkdownTextBlockCustomThemeSampleBase : Page
104104
public static readonly DependencyProperty BoldFontWeightIndexProperty =
105105
DependencyProperty.Register(nameof(BoldFontWeightIndex), typeof(int), typeof(MarkdownTextBlockCustomThemeSampleBase), new PropertyMetadata(0));
106106

107+
public static readonly DependencyProperty ListBulletSpacingProperty =
108+
DependencyProperty.Register(nameof(ListBulletSpacing), typeof(double), typeof(MarkdownTextBlockCustomThemeSampleBase), new PropertyMetadata(4d));
109+
110+
public static readonly DependencyProperty ListGutterWidthProperty =
111+
DependencyProperty.Register(nameof(ListGutterWidth), typeof(double), typeof(MarkdownTextBlockCustomThemeSampleBase), new PropertyMetadata(30d));
112+
107113
public MarkdownTextBlockCustomThemeSampleBase()
108114
{
109115
}
@@ -283,6 +289,18 @@ public int BoldFontWeightIndex
283289
set => SetValue(BoldFontWeightIndexProperty, value);
284290
}
285291

292+
public double ListBulletSpacing
293+
{
294+
get => (double)GetValue(ListBulletSpacingProperty);
295+
set => SetValue(ListBulletSpacingProperty, value);
296+
}
297+
298+
public double ListGutterWidth
299+
{
300+
get => (double)GetValue(ListGutterWidthProperty);
301+
set => SetValue(ListGutterWidthProperty, value);
302+
}
303+
286304
// Static lookup arrays
287305
public static Brush[] HeadingColors { get; } = new Brush[]
288306
{
@@ -410,6 +428,9 @@ public MarkdownThemes CreateThemes()
410428
ImageStretch = ImageStretchOptions[ImageStretchIndex],
411429

412430
BoldFontWeight = BoldFontWeights[BoldFontWeightIndex],
431+
432+
ListBulletSpacing = ListBulletSpacing,
433+
ListGutterWidth = ListGutterWidth,
413434
};
414435
}
415436

@@ -451,6 +472,9 @@ public void ResetToDefaults()
451472
ImageStretchIndex = 0;
452473

453474
BoldFontWeightIndex = 0;
475+
476+
ListBulletSpacing = 4;
477+
ListGutterWidth = 30;
454478
}
455479

456480
public abstract void ApplyTheme();

components/MarkdownTextBlock/samples/ThemeOptionsPane.xaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,29 @@
243243
</StackPanel>
244244
</muxc:Expander>
245245

246+
<!-- Lists Section -->
247+
<muxc:Expander HorizontalAlignment="Stretch"
248+
HorizontalContentAlignment="Stretch">
249+
<muxc:Expander.Header>
250+
<TextBlock FontWeight="SemiBold"
251+
Text="Lists" />
252+
</muxc:Expander.Header>
253+
<StackPanel Spacing="8">
254+
<muxc:NumberBox x:Name="ListBulletSpacingBox"
255+
Header="Bullet Spacing"
256+
Maximum="20"
257+
Minimum="0"
258+
SpinButtonPlacementMode="Compact"
259+
ValueChanged="OnValueChanged" />
260+
<muxc:NumberBox x:Name="ListGutterWidthBox"
261+
Header="Gutter Width (Indent)"
262+
Maximum="60"
263+
Minimum="10"
264+
SpinButtonPlacementMode="Compact"
265+
ValueChanged="OnValueChanged" />
266+
</StackPanel>
267+
</muxc:Expander>
268+
246269
<!-- Table Section -->
247270
<muxc:Expander HorizontalAlignment="Stretch"
248271
HorizontalContentAlignment="Stretch">

components/MarkdownTextBlock/samples/ThemeOptionsPane.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ private void LoadValuesFromSample()
6060
TableCellPaddingBox.Value = _sample.TableCellPadding;
6161
TableBorderThicknessBox.Value = _sample.TableBorderThickness;
6262

63+
// Lists
64+
ListBulletSpacingBox.Value = _sample.ListBulletSpacing;
65+
ListGutterWidthBox.Value = _sample.ListGutterWidth;
66+
6367
// Horizontal Rule
6468
HorizontalRuleThicknessBox.Value = _sample.HorizontalRuleThickness;
6569
HorizontalRuleMarginBox.Value = _sample.HorizontalRuleMargin;
@@ -108,6 +112,10 @@ private void SyncValuesToSample()
108112
_sample.TableCellPadding = TableCellPaddingBox.Value;
109113
_sample.TableBorderThickness = TableBorderThicknessBox.Value;
110114

115+
// Lists
116+
_sample.ListBulletSpacing = ListBulletSpacingBox.Value;
117+
_sample.ListGutterWidth = ListGutterWidthBox.Value;
118+
111119
// Horizontal Rule
112120
_sample.HorizontalRuleThickness = HorizontalRuleThicknessBox.Value;
113121
_sample.HorizontalRuleMargin = HorizontalRuleMarginBox.Value;

components/MarkdownTextBlock/src/TextElements/MyParagraph.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public MyParagraph(ParagraphBlock paragraphBlock, WinUIRenderer renderer)
3939
if (bulletCount != 0)
4040
{
4141
string bullet = renderer.PeekListBullet();
42-
Run bulletRun = new Run { Text = bullet + "\t" };
42+
// Use spaces to create spacing between bullet and text based on ListBulletSpacing
43+
string spacing = new string(' ', (int)themes.ListBulletSpacing);
44+
Run bulletRun = new Run { Text = bullet + spacing };
4345

4446
_paragraph.Inlines.Add(bulletRun);
4547
_paragraph.TextIndent = -themes.ListGutterWidth;

0 commit comments

Comments
 (0)