WPF.InternalDialogs
1.0.4
See the version list below for details.
dotnet add package WPF.InternalDialogs --version 1.0.4
NuGet\Install-Package WPF.InternalDialogs -Version 1.0.4
<PackageReference Include="WPF.InternalDialogs" Version="1.0.4" />
paket add WPF.InternalDialogs --version 1.0.4
#r "nuget: WPF.InternalDialogs, 1.0.4"
// Install WPF.InternalDialogs as a Cake Addin #addin nuget:?package=WPF.InternalDialogs&version=1.0.4 // Install WPF.InternalDialogs as a Cake Tool #tool nuget:?package=WPF.InternalDialogs&version=1.0.4
WPF.InternalDialogs
Easy to use LightBox-esque dialog "boxes" for WPF.
Inspired by https://github.com/BenjaminGale/ModalContentPresenter/blob/master/ModalContentPresenter/ModalContentPresenter.cs! Just built a whole message box suite on top of it.
Why
- Very easy to use!
- Works like normal message boxes do...just no separate window.
- We use the Visibility property. There is no Show or ShowDialog.
- Can be shown modally or not.
- Set the IsModal property.
- Can be completely themed without having to retemplate the controls.
- Can be retemplated if desired.
- Proper look-less control template design so can be used in EDA or MVVM development.
- Dependency properties make it so they can be assigned or bound to.
- Can be dragged by user.
- Can be resized by user.
- The MessageBoxInternalDialog has 23 different icons...not just 4.
- The MovableResizableInternalDialog makes it very easy to make your own movable resizable internal dialog if you want completely custom user interfaces.
- The resize gripper content can be whatever you want it to be as it is just a ContentPresenter. 😃
<id:MessageBoxInternalDialog x:Name="mbiDialog" Grid.Row="0" Grid.RowSpan="4"
Message="This is a simple message box."
Title="Message Box Example 1" MessageBoxImage="Information" MessageBoxButton="OKCancel"
FocusParent="{Binding ElementName=rootGrid}" />
See, very easy to use!
Wiki
Please see the wiki for type break down.
Additional Insight
FocusParent
This property is required for every InternalDialog. It will throw an exception at runtime if this value is null. This property should be some kind of root Grid, Border or Panel that contains the other focusable children. It should NOT be a singular IInputElement to pass focus back to or steal it from. You can choose various types of "re-focusing" strategies by setting CloseFocusBehavior. The default is to focus back to the control that had focus previously but you can choose first, last, next or step backwards as well.
IsModal
This property does what you would think and blocks code execution until returned. If you have a potential for multiple instances of InternalDialogs to show at the same time that are both modal then just be sure of the effects of entering another event loop when you already have one running. This is doable but might have unintended consequences for you. How IsModal works...
We push a DispatcherFrame onto the Dispatcher so that it enters a new event loop. So just be wary when showing multiple InternalDialogs of its effects on your code.
Multiple Instances
Another thing to is that you should strive to have 1 InternalDialog per window that is used to represent the same thing. MessageBoxInternalDialog doesn't need to have 2 instances in the same window. You should just put it as the top most item in your XAML (so it covers all other visual objects). You only need one generic InternalDialog at runtime because its content can be dynamic and it should just be assigned programmatically or it should be bound to. Here is the thing, you can have as many as you want but if you try to pop open 2 that have IsModal on then you might start getting behavior you might not want to occur. Just be aware of how DispatcherFrames affect your code.
Visibility
Visibility of internal dialogs binds two way by default.
Customer Gripper Made Easy
We use a ContentPresenter to paint the resize gripper so that you can put whatever kind of content you'd like for the gripper. Just be mindful that it is an 18x18 area that ever so slightly overlays the bottom right of the content with its top left points.
Custom Cursors
We thought as a part of styling you might want to change the drag cursor for the title and the resize gripper. TitleCursor and ResizeGripCursor, respectively, allow you to do that.
Custom Button Styles
We also thought that you'd want the buttons in the InternDialogs to be restylable without having to retemplate the entire control...so we added CloseButtonStyle and ButtonStyle to allow you to do just that. Please be aware that when you change the CloseButtonStyle you will have to specify your own content. This is not true for ButtonStyle. The bottom buttons will always have the content they have. If you'd like custom buttons then please consider using MovableResizableInternalDialog that allows for custom AnswerAreaContent.
ProgressInternalDialog
We gave you a ProgressBarStyle property so custom styling can be applied to the progress bar as well. The thing to note about the ProgressInternalDialog is that even though you can set the style for progress bar the value for it (if not IsIndeterminate) is still managed by the PorgressInternalDialog. Use the ProgressValue property to manage this.
Close On Escape Key Push?
Yup, we got that!
Dispose
Internal Dialogs implement IDisposable so be sure to clean up properly by calling Dispose().
Hope you enjoy. Happy coding!
Examples
Magic The Gathering Arena Deck Master
Both of these projects have really extensive examples of internal dialogs.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
-
net6.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.