Compare commits

2 Commits

Author SHA1 Message Date
Emmanuele Sassi 54a712336b EgwWPFBaseLib 3.1.8.4 :
- aggiunto EgwDropdownButton
- corretto EgwToggleButton che non gestiva trigger su IsChecked
- aggiornato progetto Demo con esempi delle modifiche fatte
2026-08-07 13:45:00 +02:00
Emmanuele Sassi d48ff13fb1 Merge branch 'main' into develop 2026-08-06 17:24:55 +02:00
6 changed files with 287 additions and 11 deletions
@@ -62,8 +62,8 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Command="{Binding SplitButtonMain_Command}" Command="{Binding SplitButtonMain_Command}"
Height="30"
Width="200" Width="200"
DropDownButtonWidth="45"
Background="Red" Background="Red"
BorderBrush="Black" BorderBrush="Black"
BorderThickness="4" BorderThickness="4"
@@ -72,16 +72,18 @@
CornerRadius="1" CornerRadius="1"
DropDownButtonBackground="Green" DropDownButtonBackground="Green"
DropDownHorizontalContentAlignment="Stretch" DropDownHorizontalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"> DropDownVerticalContentAlignment="Stretch"
DropDownButtonPadding="0"
Margin="0,0,0,10">
<EgwWPFBaseLib:EgwSplitButton.DropDownButtonContent> <EgwWPFBaseLib:EgwSplitButton.DropDownButtonContent>
<Grid Background="Blue" <Grid Background="Blue">
HorizontalAlignment="Stretch" <TextBlock Text="▼"
VerticalAlignment="Stretch"> HorizontalAlignment="Center"
<TextBlock Text="▼"/> VerticalAlignment="Center"/>
<Border Background="Red" <Border Background="Red"
Height="10" Height="10"
Width="10" Width="10"
Margin="5,0,0,0" Margin="5,1,1,0"
CornerRadius="5" CornerRadius="5"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalAlignment="Right" HorizontalAlignment="Right"
@@ -110,6 +112,36 @@
</Border> </Border>
</EgwWPFBaseLib:EgwSplitButton.DropDownContent> </EgwWPFBaseLib:EgwSplitButton.DropDownContent>
</EgwWPFBaseLib:EgwSplitButton> </EgwWPFBaseLib:EgwSplitButton>
<EgwWPFBaseLib:EgwDropdownButton HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="30"
Width="30"
Background="Red"
BorderBrush="Black"
BorderThickness="4"
CornerRadius="1"
Margin="0,0,0,10">
<EgwWPFBaseLib:EgwDropdownButton.DropDownContent>
<Border BorderBrush="Aqua"
BorderThickness="2"
CornerRadius="5">
<StackPanel>
<EgwWPFBaseLib:EgwButton Content="Bottone interno"
Command="{Binding SplitButton1Popup_Command}"
CornerRadius="4"/>
<EgwWPFBaseLib:EgwButton Content="Bottone interno 2"
Command="{Binding SplitButton2Popup_Command}"
CornerRadius="4"/>
</StackPanel>
</Border>
</EgwWPFBaseLib:EgwDropdownButton.DropDownContent>
</EgwWPFBaseLib:EgwDropdownButton>
<EgwWPFBaseLib:EgwToggleButton HorizontalAlignment="Center"
VerticalAlignment="Center"
Height="30"
Width="30">
</EgwWPFBaseLib:EgwToggleButton>
</StackPanel> </StackPanel>
@@ -52,5 +52,5 @@ Imports System.Windows
' Revision ' Revision
' '
<Assembly: AssemblyVersion("3.1.8.3")> <Assembly: AssemblyVersion("3.1.8.4")>
<Assembly: AssemblyFileVersion("3.1.8.3")> <Assembly: AssemblyFileVersion("3.1.8.4")>
@@ -0,0 +1,168 @@
' Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
'
' Step 1a) Using this custom control in a XAML file that exists in the current project.
' Add this XmlNamespace attribute to the root element of the markup file where it is
' to be used:
'
' xmlns:MyNamespace="clr-namespace:EgwWPFBaseLib"
'
'
' Step 1b) Using this custom control in a XAML file that exists in a different project.
' Add this XmlNamespace attribute to the root element of the markup file where it is
' to be used:
'
' xmlns:MyNamespace="clr-namespace:EgwWPFBaseLib;assembly=EgwWPFBaseLib"
'
' You will also need to add a project reference from the project where the XAML file lives
' to this project and Rebuild to avoid compilation errors:
'
' Right click on the target project in the Solution Explorer and
' "Add Reference"->"Projects"->[Browse to and select this project]
'
'
' Step 2)
' Go ahead and use your control in the XAML file. Note that Intellisense in the
' XML editor does not currently work on custom controls and its child elements.
'
' <MyNamespace:EgwDropdown/>
'
Imports System.Windows.Controls.Primitives
Public Class EgwDropdownButton
Inherits EgwToggleButton
Public Enum PopupPlacementType
BottomLeft
BottomCenter
BottomRight
TopLeft
TopCenter
TopRight
LeftTop
LeftCenter
LeftBottom
RightTop
RightCenter
RightBottom
End Enum
Public Property DropDownContent As Object
Get
Return GetValue(DropDownContentProperty)
End Get
Set(value As Object)
SetValue(DropDownContentProperty, value)
End Set
End Property
Public Shared ReadOnly DropDownContentProperty As DependencyProperty =
DependencyProperty.Register("DropDownContent",
GetType(Object),
GetType(EgwDropdownButton),
New PropertyMetadata(Nothing))
' --- Placement del popup ---
Public Property PopupPlacement As PopupPlacementType
Get
Return CType(GetValue(PopupPlacementProperty), PopupPlacementType)
End Get
Set(value As PopupPlacementType)
SetValue(PopupPlacementProperty, value)
End Set
End Property
Public Shared ReadOnly PopupPlacementProperty As DependencyProperty =
DependencyProperty.Register("PopupPlacement",
GetType(PopupPlacementType),
GetType(EgwDropdownButton),
New PropertyMetadata(PopupPlacementType.BottomLeft))
Shared Sub New()
'This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
'This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(GetType(EgwDropdownButton), New FrameworkPropertyMetadata(GetType(EgwDropdownButton)))
End Sub
Public Overrides Sub OnApplyTemplate()
MyBase.OnApplyTemplate()
Dim popup = TryCast(GetTemplateChild("PART_Popup"), Popup)
Dim root = TryCast(Me, FrameworkElement)
If popup Is Nothing OrElse root Is Nothing Then Return
' PlacementTarget deve essere il controllo, non la freccia
popup.PlacementTarget = root
AddHandler popup.Opened,
Sub()
Dim child = popup.Child
child.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
Dim popupWidth = child.DesiredSize.Width
Dim popupHeight = child.DesiredSize.Height
Dim rootWidth = root.ActualWidth
Dim rootHeight = root.ActualHeight
popup.HorizontalOffset = 0
popup.VerticalOffset = 0
Select Case PopupPlacement
' --- BOTTOM ---
Case PopupPlacementType.BottomLeft
popup.Placement = PlacementMode.Bottom
Case PopupPlacementType.BottomCenter
popup.Placement = PlacementMode.Bottom
popup.HorizontalOffset = (rootWidth - popupWidth) / 2
Case PopupPlacementType.BottomRight
popup.Placement = PlacementMode.Bottom
popup.HorizontalOffset = rootWidth - popupWidth
' --- TOP ---
Case PopupPlacementType.TopLeft
popup.Placement = PlacementMode.Top
Case PopupPlacementType.TopCenter
popup.Placement = PlacementMode.Top
popup.HorizontalOffset = (rootWidth - popupWidth) / 2
Case PopupPlacementType.TopRight
popup.Placement = PlacementMode.Top
popup.HorizontalOffset = rootWidth - popupWidth
' --- LEFT ---
Case PopupPlacementType.LeftTop
popup.Placement = PlacementMode.Left
Case PopupPlacementType.LeftCenter
popup.Placement = PlacementMode.Left
popup.VerticalOffset = (rootHeight - popupHeight) / 2
Case PopupPlacementType.LeftBottom
popup.Placement = PlacementMode.Left
popup.VerticalOffset = rootHeight - popupHeight
' --- RIGHT ---
Case PopupPlacementType.RightTop
popup.Placement = PlacementMode.Right
Case PopupPlacementType.RightCenter
popup.Placement = PlacementMode.Right
popup.VerticalOffset = (rootHeight - popupHeight) / 2
Case PopupPlacementType.RightBottom
popup.Placement = PlacementMode.Right
popup.VerticalOffset = rootHeight - popupHeight
End Select
End Sub
End Sub
End Class
+1
View File
@@ -96,6 +96,7 @@
<Compile Include="EgwButton\EgwButton.vb" /> <Compile Include="EgwButton\EgwButton.vb" />
<Compile Include="EgwDataGrid\ColumnLayout.vb" /> <Compile Include="EgwDataGrid\ColumnLayout.vb" />
<Compile Include="EgwDataGrid\EgwDataGrid.vb" /> <Compile Include="EgwDataGrid\EgwDataGrid.vb" />
<Compile Include="EgwDropdownButton\EgwDropdownButton.vb" />
<Compile Include="EgwRightFrozenDataGrid\EgwRightFrozenColumn.vb" /> <Compile Include="EgwRightFrozenDataGrid\EgwRightFrozenColumn.vb" />
<Compile Include="EgwRightFrozenDataGrid\EgwRightFrozenDataGrid.xaml.vb"> <Compile Include="EgwRightFrozenDataGrid\EgwRightFrozenDataGrid.xaml.vb">
<DependentUpon>EgwRightFrozenDataGrid.xaml</DependentUpon> <DependentUpon>EgwRightFrozenDataGrid.xaml</DependentUpon>
+2 -2
View File
@@ -52,5 +52,5 @@ Imports System.Windows
' Revision ' Revision
' '
<Assembly: AssemblyVersion("3.1.8.3")> <Assembly: AssemblyVersion("3.1.8.4")>
<Assembly: AssemblyFileVersion("3.1.8.3")> <Assembly: AssemblyFileVersion("3.1.8.4")>
+75
View File
@@ -227,6 +227,81 @@
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/> <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/> <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}"/>
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}"/>
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:EgwDropdownButton}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Content" Value="▼"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="PopupPlacement" Value="BottomRight"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:EgwDropdownButton}">
<Grid>
<Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" CornerRadius="{TemplateBinding CornerRadius}">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<!-- Popup generico -->
<Popup x:Name="PART_Popup"
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
StaysOpen="False"
AllowsTransparency="True"
PopupAnimation="Fade"
IsOpen="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}}">
<ContentPresenter Content="{TemplateBinding DropDownContent}"/>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}"/>
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter TargetName="border" Property="Background" Value="{StaticResource Button.Pressed.Background}"/>
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Border}"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false"> <Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/> <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/> <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>