Skip to content

Commit 6b73f77

Browse files
author
Corvin Szimion
committed
Merge branch 'fix3628SliderToolTipOnClick' of https://github.com/corvinsz/MaterialDesignInXamlToolkit into fix3628SliderToolTipOnClick
2 parents e1a6487 + 15daeba commit 6b73f77

20 files changed

+165
-76
lines changed

.github/workflows/pr_verification.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
contents: write
3030

3131
steps:
32-
- uses: fastify/github-action-merge-dependabot@v3.10.2
32+
- uses: fastify/github-action-merge-dependabot@v3.11.0

src/MainDemo.Wpf/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
<Setter Property="Height" Value="1" />
144144
<Setter Property="Fill" Value="{DynamicResource MaterialDesignDivider}" />
145145
</Style>
146+
146147
</ResourceDictionary>
147148
</Application.Resources>
148149
</Application>

src/MainDemo.Wpf/Fields.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,20 @@
671671
</smtx:XamlDisplay>
672672
</StackPanel>
673673

674+
<Rectangle Style="{StaticResource PageSectionSeparator}" />
675+
<TextBlock Style="{StaticResource PageSectionTitleTextBlock}" Text="Custom Background" />
676+
677+
<WrapPanel Margin="0,0,0,32" Background="Chocolate">
678+
<smtx:XamlDisplay Margin="16"
679+
UniqueKey="fields_custom_background_1">
680+
<TextBox Width="200"
681+
Style="{StaticResource MaterialDesignOutlinedTextBox}"
682+
materialDesign:HintAssist.Hint="Hint text"
683+
materialDesign:HintAssist.HintPaddingBrush="Chocolate" />
684+
<!-- Set HintAssist.HintPaddingBrush to match the custom background to get correct coloring of the hint padding (when floated) -->
685+
</smtx:XamlDisplay>
686+
</WrapPanel>
687+
674688
<Rectangle Style="{StaticResource PageSectionSeparator}" />
675689
<TextBlock Style="{StaticResource PageSectionTitleTextBlock}" Text="AutoSuggestBox" />
676690

src/MainDemo.Wpf/MenusAndToolBars.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@
216216

217217
<Separator />
218218

219-
<ListBox>
220-
<ListBoxItem ToolTip="This is a lonley toggle with TextBlock instead of icon">
219+
<ListBox materialDesign:ListBoxAssist.CanUserToggleSelectedItem="True">
220+
<ListBoxItem ToolTip="This is a lonely toggle with TextBlock instead of icon">
221221
<TextBlock Text="W" />
222222
</ListBoxItem>
223223
</ListBox>

src/MaterialDesign3.Demo.Wpf/Fields.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,5 +518,19 @@
518518
</smtx:XamlDisplay>
519519
</StackPanel>
520520
</Grid>
521+
522+
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" Text="Custom Background" Margin="0,20,0,0" />
523+
524+
<WrapPanel Margin="0,0,0,32" Background="Chocolate">
525+
<smtx:XamlDisplay Margin="16"
526+
UniqueKey="fields_custom_background_1">
527+
<TextBox Width="200"
528+
Style="{StaticResource MaterialDesignOutlinedTextBox}"
529+
materialDesign:HintAssist.Hint="Hint text"
530+
materialDesign:HintAssist.HintPaddingBrush="Chocolate" />
531+
<!-- Set HintAssist.HintPaddingBrush to match the custom background to get correct coloring of the hint padding (when floated) -->
532+
</smtx:XamlDisplay>
533+
</WrapPanel>
534+
521535
</StackPanel>
522536
</UserControl>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Microsoft.Xaml.Behaviors;
2+
3+
namespace MaterialDesignThemes.Wpf.Behaviors;
4+
5+
public class SmartHintBehavior : Behavior<SmartHint>
6+
{
7+
public static readonly DependencyProperty YOffsetProperty =
8+
DependencyProperty.RegisterAttached("YOffset", typeof(double), typeof(SmartHintBehavior), new PropertyMetadata(0.0));
9+
public static double GetYOffset(DependencyObject obj)
10+
=> (double)obj.GetValue(YOffsetProperty);
11+
public static void SetYOffset(DependencyObject obj, double value)
12+
=> obj.SetValue(YOffsetProperty, value);
13+
14+
private void UpdateSmartHintLocationRecalculationTrigger()
15+
{
16+
if (AssociatedObject?.FloatingTarget is null) return;
17+
18+
double yOffset = AssociatedObject.FloatingTarget.TranslatePoint(new Point(0, 0), AssociatedObject).Y;
19+
AssociatedObject.SetCurrentValue(YOffsetProperty, yOffset);
20+
}
21+
22+
private void HintHostOnLayoutUpdated(object? sender, EventArgs e)
23+
=> UpdateSmartHintLocationRecalculationTrigger();
24+
25+
protected override void OnAttached()
26+
{
27+
base.OnAttached();
28+
AssociatedObject.LayoutUpdated += HintHostOnLayoutUpdated;
29+
}
30+
31+
protected override void OnDetaching()
32+
{
33+
if (AssociatedObject != null)
34+
{
35+
AssociatedObject.LayoutUpdated -= HintHostOnLayoutUpdated;
36+
}
37+
base.OnDetaching();
38+
}
39+
}

src/MaterialDesignThemes.Wpf/Converters/FloatingHintTranslateTransformConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Globalization;
1+
using System.Globalization;
22
using System.Windows.Data;
33
using System.Windows.Media;
44

@@ -8,7 +8,7 @@ public class FloatingHintTranslateTransformConverter : IMultiValueConverter
88
{
99
public object? Convert(object?[]? values, Type targetType, object? parameter, CultureInfo culture)
1010
{
11-
if (values is not [double scale, double lower, double upper, SmartHint hint, Point floatingOffset, ..])
11+
if (values is not [double scale, double lower, double upper, SmartHint hint, Point floatingOffset, double yOffset, ..])
1212
{
1313
return Transform.Identity;
1414
}
@@ -43,7 +43,7 @@ double GetFloatingTargetHorizontalOffset()
4343

4444
double GetFloatingTargetVerticalOffset()
4545
{
46-
double offset = hint.FloatingTarget.TranslatePoint(new Point(0, 0), hint).Y;
46+
double offset = yOffset;
4747
offset += hint.InitialVerticalOffset;
4848
offset -= hint.ActualHeight;
4949

src/MaterialDesignThemes.Wpf/HintAssist.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ public static void SetBackground(DependencyObject element, Brush value)
119119
=> element.SetValue(BackgroundProperty, value);
120120
#endregion
121121

122+
#region AttachedProperty: HintPaddingBrush
123+
public static readonly DependencyProperty HintPaddingBrushProperty =
124+
DependencyProperty.RegisterAttached("HintPaddingBrush", typeof(Brush), typeof(HintAssist), new PropertyMetadata(null));
125+
126+
public static Brush? GetHintPaddingBrush(DependencyObject obj)
127+
=> (Brush)obj.GetValue(HintPaddingBrushProperty);
128+
129+
public static void SetHintPaddingBrush(DependencyObject obj, Brush? value)
130+
=> obj.SetValue(HintPaddingBrushProperty, value);
131+
#endregion
132+
122133
#region AttachedProperty : HelperTextProperty
123134
public static readonly DependencyProperty HelperTextProperty
124135
= DependencyProperty.RegisterAttached("HelperText", typeof(string), typeof(HintAssist),

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,22 @@
156156
VerticalScrollBarVisibility="Hidden" />
157157

158158
<wpf:SmartHint x:Name="Hint"
159-
Grid.Column="1"
160-
Grid.ColumnSpan="3"
161-
VerticalAlignment="Center"
162-
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
163-
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
164-
FloatingOffset="{TemplateBinding wpf:HintAssist.FloatingOffset}"
165-
FloatingScale="{TemplateBinding wpf:HintAssist.FloatingScale}"
166-
FontFamily="{TemplateBinding wpf:HintAssist.FontFamily}"
167-
FontSize="{TemplateBinding FontSize}"
168-
HintOpacity="{TemplateBinding wpf:HintAssist.HintOpacity}"
169-
HintProxy="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:HintProxyFabricConverter.Instance}}"
170-
UseFloating="{TemplateBinding wpf:HintAssist.IsFloating}"
171-
FloatingTarget="{Binding ElementName=PART_ContentHost}"
172-
HintHost="{Binding RelativeSource={RelativeSource TemplatedParent}}"
173-
wpf:HintAssist.Background="{TemplateBinding wpf:HintAssist.Background}">
159+
Grid.Column="1"
160+
Grid.ColumnSpan="3"
161+
VerticalAlignment="Center"
162+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
163+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
164+
FloatingOffset="{TemplateBinding wpf:HintAssist.FloatingOffset}"
165+
FloatingScale="{TemplateBinding wpf:HintAssist.FloatingScale}"
166+
FontFamily="{TemplateBinding wpf:HintAssist.FontFamily}"
167+
FontSize="{TemplateBinding FontSize}"
168+
HintOpacity="{TemplateBinding wpf:HintAssist.HintOpacity}"
169+
HintProxy="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:HintProxyFabricConverter.Instance}}"
170+
UseFloating="{TemplateBinding wpf:HintAssist.IsFloating}"
171+
FloatingTarget="{Binding ElementName=PART_ContentHost}"
172+
HintHost="{Binding RelativeSource={RelativeSource TemplatedParent}}"
173+
wpf:HintAssist.Background="{TemplateBinding wpf:HintAssist.Background}"
174+
wpf:HintAssist.HintPaddingBrush="{TemplateBinding wpf:HintAssist.HintPaddingBrush}">
174175
<wpf:SmartHint.InitialHorizontalOffset>
175176
<MultiBinding Converter="{StaticResource FloatingHintInitialHorizontalOffsetConverter}">
176177
<Binding ElementName="PrefixTextBlock" Path="ActualWidth" />
@@ -369,14 +370,6 @@
369370
<Setter TargetName="Hint" Property="FloatingMargin" Value="4,0" />
370371
<Setter TargetName="Hint" Property="InitialVerticalOffset" Value="{Binding ElementName=Hint, Path=ActualHeight, Converter={StaticResource DivisionConverter}, ConverterParameter=2}" />
371372
</Trigger>
372-
<MultiTrigger>
373-
<MultiTrigger.Conditions>
374-
<Condition Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True" />
375-
<Condition Property="wpf:HintAssist.IsFloating" Value="True" />
376-
<Condition SourceName="Hint" Property="IsHintInFloatingPosition" Value="True" />
377-
</MultiTrigger.Conditions>
378-
<Setter TargetName="Hint" Property="wpf:HintAssist.Background" Value="{DynamicResource MaterialDesign.Brush.Background}" />
379-
</MultiTrigger>
380373

381374
<!-- IsEnabled -->
382375
<MultiTrigger>

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,14 @@
154154
</Setter.Value>
155155
</Setter>
156156
<Setter Property="VerticalContentAlignment" Value="Center" />
157-
<Setter Property="Width" Value="48" />
157+
<Setter Property="MinWidth" Value="48" />
158158
<Setter Property="wpf:CalendarAssist.SelectionColor" Value="{DynamicResource MaterialDesign.Brush.Primary}" />
159159
<Setter Property="wpf:CalendarAssist.SelectionForegroundColor" Value="{DynamicResource MaterialDesign.Brush.Primary.Foreground}" />
160160
</Style>
161161

162162
<Style x:Key="MaterialDesignCalendarDayButton" TargetType="{x:Type CalendarDayButton}">
163163
<Setter Property="Cursor" Value="Hand" />
164164
<Setter Property="FontSize" Value="12" />
165-
<Setter Property="Height" Value="28" />
166165
<Setter Property="HorizontalContentAlignment" Value="Center" />
167166
<Setter Property="Margin" Value="2" />
168167
<Setter Property="MinHeight" Value="5" />
@@ -317,7 +316,8 @@
317316
</Setter.Value>
318317
</Setter>
319318
<Setter Property="VerticalContentAlignment" Value="Center" />
320-
<Setter Property="Width" Value="28" />
319+
<Setter Property="MinWidth" Value="28" />
320+
<Setter Property="MinHeight" Value="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"/>
321321
<Setter Property="wpf:CalendarAssist.SelectionColor" Value="{DynamicResource MaterialDesign.Brush.Primary}" />
322322
<Setter Property="wpf:CalendarAssist.SelectionForegroundColor" Value="{DynamicResource MaterialDesign.Brush.Primary.Foreground}" />
323323
<Style.Triggers>

0 commit comments

Comments
 (0)