├── .gitattributes ├── .gitignore ├── Docs ├── Screenshots │ ├── CriticalDialog.png │ ├── Demo.gif │ ├── ErrorDialog.png │ ├── InformationDialog.png │ ├── InputDialog.png │ ├── ProgressDialogs.gif │ ├── SuccessDialog.png │ └── WarningDialog.png └── logo.png ├── LICENSE ├── README.md ├── SimpleDialogs.Demo ├── App.config ├── App.xaml ├── App.xaml.cs ├── FodyWeavers.xml ├── Helpers │ ├── MarginSetterHelper.cs │ └── SpacingHelper.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ └── logo.png ├── SimpleDialogs.Demo.csproj ├── ViewModel │ ├── MainViewModel.cs │ └── ViewModelLocator.cs ├── icon.ico └── packages.config ├── SimpleDialogs.sln └── SimpleDialogs ├── Commands └── SimpleCommand.cs ├── Controls ├── BaseDialog.cs ├── DialogButtonClickedEventArgs.cs ├── DialogClosedEventArgs.cs ├── DialogContainer.cs ├── InputDialog.cs ├── MessageDialog.cs ├── ProgressDialog.cs └── ProgressRing.cs ├── Design ├── BaseDialog.xaml ├── DialogContainer.xaml ├── InputDialog.xaml ├── MessageDialog.xaml ├── ProgressDialog.xaml └── ProgressRing.xaml ├── DialogManager.cs ├── Enumerators ├── DialogButton.cs └── MessageSeverity.cs ├── Helpers └── KeyboardHelper.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Resources └── SquareButtonStyle.xaml ├── SimpleDialogs.csproj ├── SimpleDialogs.nuspec ├── TemplateSelectors └── MessageDialogIconSelector.cs ├── Themes ├── Dark.xaml ├── DefaultColors.xaml ├── Generic.xaml └── Light.xaml └── ValueConverters ├── BoolToVisibilityConverter.cs ├── NullToVisibilityConverter.cs └── PercentageConverter.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | SimpleDialogs/nuget.exe 290 | -------------------------------------------------------------------------------- /Docs/Screenshots/CriticalDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/CriticalDialog.png -------------------------------------------------------------------------------- /Docs/Screenshots/Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/Demo.gif -------------------------------------------------------------------------------- /Docs/Screenshots/ErrorDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/ErrorDialog.png -------------------------------------------------------------------------------- /Docs/Screenshots/InformationDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/InformationDialog.png -------------------------------------------------------------------------------- /Docs/Screenshots/InputDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/InputDialog.png -------------------------------------------------------------------------------- /Docs/Screenshots/ProgressDialogs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/ProgressDialogs.gif -------------------------------------------------------------------------------- /Docs/Screenshots/SuccessDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/SuccessDialog.png -------------------------------------------------------------------------------- /Docs/Screenshots/WarningDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/Screenshots/WarningDialog.png -------------------------------------------------------------------------------- /Docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schdck/SimpleDialogs/d5bdc4ac9599e8b59ee739ce6fcf42f610b4e6e4/Docs/logo.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maurício Vielmo Schmaedeck 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | [](https://github.com/schdck/SimpleDialogs) 4 | 5 | # SimpleDialogs 6 | 7 | [![License](https://img.shields.io/github/license/schdck/SimpleDialogs.svg)](https://github.com/schdck/SimpleDialogs/blob/master/LICENSE) 8 | [![Build status](https://ci.appveyor.com/api/projects/status/ngnm9ni9rckwg4v4?svg=true)](https://ci.appveyor.com/project/schdck/simpledialogs) 9 | [![NuGet](https://img.shields.io/nuget/v/SimpleDialogs.svg)](https://www.nuget.org/packages/SimpleDialogs/) 10 | [![NuGet](https://img.shields.io/nuget/dt/SimpleDialogs.svg)](https://www.nuget.org/packages/SimpleDialogs/) 11 | [![GitHub issues](https://img.shields.io/github/issues/schdck/SimpleDialogs.svg)](https://github.com/schdck/SimpleDialogs/issues) 12 | 13 | 14 | 15 | :speech_balloon: SimpleDialogs is a simple framework to help displaying dialogs on a WPF app 16 |
17 | 18 |
19 | 20 | ## :bulb: About the project 21 | I made this project to make my life easier when displaying messages to the user, since it was something that I saw myself implementing over and over again. Also, I used it to practice a few new concepts that I was studying. It is far from perfect, but its something I'm proud of. 22 | 23 | Also: any help, tips, suggestions or critics are really appreciated. 24 | 25 | This project was heavily inspired/based on [Mahapps.Metro](https://github.com/MahApps/MahApps.Metro) (and its dialogs) and on [Mahapps.Metro.SimpleChildWindow](https://github.com/punker76/MahApps.Metro.SimpleChildWindow), so a special thanks to [@punker76](https://github.com/punker76) and all the other maintainers/contributors. 26 | 27 | ## :rocket: Getting started 28 | 29 | You can install SimpleDialogs through [NuGet](https://www.nuget.org/packages/SimpleDialogs/) by running the following command in the NuGet Package Manager Console 30 | 31 | ```bash 32 | PM> Install-Package SimpleDialogs 33 | ``` 34 | 35 | ... or through NuGet Package Manager directly on your project/solution. 36 | 37 | Then just add one of the following `Resource Dictionary` 38 | 39 | ```XML 40 | 41 | 42 | 43 | 44 | ``` 45 | 46 | ... to your application resources and you are good to go! 47 | 48 | **Also take a look at our :dart: [Quick start](https://github.com/schdck/SimpleDialogs/wiki/Quick-start) and at the :books: [Wiki](https://github.com/schdck/SimpleDialogs/wiki)** 49 | 50 | ## :camera: Screenshots 51 | 52 | #### Progress dialogs 53 | 56 | 57 | #### Information dialog 58 | 61 | 62 | #### Success dialog 63 | 66 | 67 | #### Warning dialog 68 | 71 | 72 | #### Error dialog 73 | 76 | 77 | #### Critical error dialog 78 | 81 | 82 | #### Input dialog 83 | 86 | 87 | #### Demo application 88 | 91 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/App.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace SimpleDialogs.Demo 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/Helpers/MarginSetterHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace SimpleDialogs.Demo.Helpers 5 | { 6 | /* FROM: https://gist.github.com/angularsen/90040fb174f71c5ab3ad 7 | */ 8 | public class MarginSetter 9 | { 10 | private static Thickness GetLastItemMargin(Panel obj) 11 | { 12 | return (Thickness)obj.GetValue(LastItemMarginProperty); 13 | } 14 | 15 | public static Thickness GetMargin(DependencyObject obj) 16 | { 17 | return (Thickness)obj.GetValue(MarginProperty); 18 | } 19 | 20 | private static void MarginChangedCallback(object sender, DependencyPropertyChangedEventArgs e) 21 | { 22 | // Make sure this is put on a panel 23 | var panel = sender as Panel; 24 | if (panel == null) return; 25 | 26 | // Avoid duplicate registrations 27 | panel.Loaded -= OnPanelLoaded; 28 | panel.Loaded += OnPanelLoaded; 29 | 30 | if (panel.IsLoaded) 31 | { 32 | OnPanelLoaded(panel, null); 33 | } 34 | } 35 | 36 | private static void OnPanelLoaded(object sender, RoutedEventArgs e) 37 | { 38 | var panel = (Panel)sender; 39 | 40 | // Go over the children and set margin for them: 41 | for (var i = 0; i < panel.Children.Count; i++) 42 | { 43 | UIElement child = panel.Children[i]; 44 | var fe = child as FrameworkElement; 45 | if (fe == null) continue; 46 | 47 | bool isLastItem = i == panel.Children.Count - 1; 48 | fe.Margin = isLastItem ? GetLastItemMargin(panel) : GetMargin(panel); 49 | } 50 | } 51 | 52 | public static void SetLastItemMargin(DependencyObject obj, Thickness value) 53 | { 54 | obj.SetValue(LastItemMarginProperty, value); 55 | } 56 | 57 | public static void SetMargin(DependencyObject obj, Thickness value) 58 | { 59 | obj.SetValue(MarginProperty, value); 60 | } 61 | 62 | // Using a DependencyProperty as the backing store for Margin. This enables animation, styling, binding, etc... 63 | public static readonly DependencyProperty MarginProperty = 64 | DependencyProperty.RegisterAttached("Margin", typeof(Thickness), typeof(MarginSetter), 65 | new UIPropertyMetadata(new Thickness(), MarginChangedCallback)); 66 | 67 | public static readonly DependencyProperty LastItemMarginProperty = 68 | DependencyProperty.RegisterAttached("LastItemMargin", typeof(Thickness), typeof(MarginSetter), 69 | new UIPropertyMetadata(new Thickness(), MarginChangedCallback)); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/Helpers/SpacingHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SimpleDialogs.Demo.Helpers 4 | { 5 | public class Spacing 6 | { 7 | public static double GetHorizontal(DependencyObject obj) 8 | { 9 | return (double)obj.GetValue(HorizontalProperty); 10 | } 11 | 12 | public static double GetVertical(DependencyObject obj) 13 | { 14 | return (double)obj.GetValue(VerticalProperty); 15 | } 16 | 17 | private static void HorizontalChangedCallback(object sender, DependencyPropertyChangedEventArgs e) 18 | { 19 | var space = (double)e.NewValue; 20 | var obj = (DependencyObject)sender; 21 | 22 | MarginSetter.SetMargin(obj, new Thickness(0, 0, space, 0)); 23 | MarginSetter.SetLastItemMargin(obj, new Thickness(0)); 24 | } 25 | 26 | public static void SetHorizontal(DependencyObject obj, double space) 27 | { 28 | obj.SetValue(HorizontalProperty, space); 29 | } 30 | 31 | public static void SetVertical(DependencyObject obj, double value) 32 | { 33 | obj.SetValue(VerticalProperty, value); 34 | } 35 | 36 | private static void VerticalChangedCallback(object sender, DependencyPropertyChangedEventArgs e) 37 | { 38 | var space = (double)e.NewValue; 39 | var obj = (DependencyObject)sender; 40 | MarginSetter.SetMargin(obj, new Thickness(0, 0, 0, space)); 41 | MarginSetter.SetLastItemMargin(obj, new Thickness(0)); 42 | } 43 | 44 | public static readonly DependencyProperty VerticalProperty = 45 | DependencyProperty.RegisterAttached("Vertical", typeof(double), typeof(Spacing), 46 | new UIPropertyMetadata(0d, VerticalChangedCallback)); 47 | 48 | public static readonly DependencyProperty HorizontalProperty = 49 | DependencyProperty.RegisterAttached("Horizontal", typeof(double), typeof(Spacing), 50 | new UIPropertyMetadata(0d, HorizontalChangedCallback)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /SimpleDialogs.Demo/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  18 | 19 | 20 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 47 | 48 | 49 | 50 | 51 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |