Skip to content

Commit f6aa3d6

Browse files
committed
Merge pull request #239 from hshahdoost/RTL
MaterialDesignMultiFloatingActionPopupBox RTL bug fixed
2 parents 08b7969 + 3fdd513 commit f6aa3d6

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

MaterialDesignThemes.Wpf/ComboBoxPopup.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,16 @@ private CustomPopupPlacement[] ComboBoxCustomPopupPlacementCallback(Size popupSi
116116
var locationY = (int)locationFromScreen.Y % screenHeight;
117117

118118
var realOffsetX = (popupSize.Width - targetSize.Width) / 2.0;
119-
var offsetX = DpiHelper.TransformToDeviceX(mainVisual, offset.X);
119+
120+
double offsetX;
121+
const int rtlHorizontalOffset = 20;
122+
123+
if (FlowDirection == FlowDirection.LeftToRight)
124+
offsetX = DpiHelper.TransformToDeviceX(mainVisual, offset.X);
125+
else
126+
offsetX = DpiHelper.TransformToDeviceX(mainVisual,
127+
offset.X - targetSize.Width - rtlHorizontalOffset);
128+
120129
var defaultVerticalOffsetIndepent = DpiHelper.TransformToDeviceY(mainVisual, DefaultVerticalOffset);
121130
var upVerticalOffsetIndepent = DpiHelper.TransformToDeviceY(mainVisual, UpVerticalOffset);
122131
var downVerticalOffsetIndepent = DpiHelper.TransformToDeviceY(mainVisual, DownVerticalOffset);

MaterialDesignThemes.Wpf/PackIcon.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ public class PackIcon : PackIconBase<PackIconKind>
1717
static PackIcon()
1818
{
1919
DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIcon), new FrameworkPropertyMetadata(typeof(PackIcon)));
20-
}
20+
}
2121

22-
public PackIcon() : base(PackIconDataFactory.Create)
23-
{ }
22+
public PackIcon() : base(PackIconDataFactory.Create) { }
2423
}
2524
}

MaterialDesignThemes.Wpf/PopupBox.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace MaterialDesignThemes.Wpf
2222
public enum PopupBoxPlacementMode
2323
{
2424
/// <summary>
25-
/// Display the popup below the toggle, and align the left edges.
25+
/// Display the popup below the toggle, and align the left edges.3
2626
/// </summary>
2727
BottomAndAlignLeftEdges,
2828
/// <summary>
@@ -400,6 +400,12 @@ protected void Close()
400400
private CustomPopupPlacement[] GetPopupPlacement(Size popupSize, Size targetSize, Point offset)
401401
{
402402
double x, y;
403+
404+
405+
if (FlowDirection == FlowDirection.RightToLeft)
406+
offset.X += targetSize.Width / 2;
407+
408+
403409
switch (PlacementMode)
404410
{
405411
case PopupBoxPlacementMode.BottomAndAlignLeftEdges:

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,13 +787,14 @@
787787
<Setter Property="HorizontalAlignment" Value="Left" />
788788
<Setter Property="VerticalAlignment" Value="Top" />
789789
<Setter Property="IsTabStop" Value="False" />
790+
<Setter Property="FlowDirection" Value="LeftToRight" />
790791
<Setter Property="Template">
791792
<Setter.Value>
792793
<ControlTemplate TargetType="{x:Type local:PackIcon}">
793794
<Border Background="{TemplateBinding Background}"
794795
BorderBrush="{TemplateBinding BorderBrush}"
795796
BorderThickness="{TemplateBinding BorderThickness}">
796-
<Viewbox>
797+
<Viewbox FlowDirection="{TemplateBinding FlowDirection}">
797798
<Canvas Width="24" Height="24">
798799
<Path Data="{Binding Data, RelativeSource={RelativeSource TemplatedParent}}"
799800
Fill="{TemplateBinding Foreground}" />

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.CheckBox.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
<ColumnDefinition Width="Auto"/>
8383
<ColumnDefinition Width="*"/>
8484
</Grid.ColumnDefinitions>
85-
<Viewbox Width="18" Height="18" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
85+
<Viewbox Width="18" Height="18" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
86+
FlowDirection="LeftToRight">
8687
<Canvas Width="24" Height="24">
8788
<Path x:Name="Graphic"
8889
Data="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z"

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToggleButton.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</VisualStateManager.VisualStateGroups>
137137
<Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" x:Name="UncheckedEllipse" Opacity=".54" />
138138
<Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" x:Name="CheckedEllipse" />
139-
<Viewbox Width="24" Height="24" x:Name="CheckMark" Visibility="Hidden" HorizontalAlignment="Center" VerticalAlignment="Center">
139+
<Viewbox Width="24" Height="24" x:Name="CheckMark" Visibility="Hidden" HorizontalAlignment="Center" VerticalAlignment="Center" FlowDirection="LeftToRight">
140140
<Canvas Width="24" Height="24">
141141
<Path Data="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" Fill="{TemplateBinding Foreground}" />
142142
</Canvas>

0 commit comments

Comments
 (0)