Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContentDialog resize improvements #612

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 43 additions & 36 deletions src/Wpf.Ui.Gallery/Controls/TermsOfUseContentDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,62 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="Terms of use"
d:DesignHeight="880"
d:DesignWidth="800"
d:DesignHeight="1000"
d:DesignWidth="750"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
CloseButtonText="Close"
DialogMaxWidth="750"
mc:Ignorable="d">

<ui:ContentDialog.Resources>
<Style BasedOn="{StaticResource {x:Type ui:ContentDialog}}" TargetType="{x:Type local:TermsOfUseContentDialog}" />
</ui:ContentDialog.Resources>

<Grid>
<StackPanel>
<TextBlock TextWrapping="WrapWithOverflow">
<Run>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque luctus malesuada mollis. Ut placerat dolor ac ligula consectetur, aliquam viverra odio dignissim. Donec in finibus tortor. Suspendisse eget ipsum vel arcu feugiat porttitor. Mauris et arcu pretium ipsum posuere tincidunt at a magna. Nullam finibus, arcu sit amet convallis sollicitudin, odio nisi efficitur mauris, quis aliquam dolor velit ac est. Integer quis ante velit. Etiam tincidunt, purus ut tempus auctor, sem augue congue urna, a vulputate mauris tortor a enim. Sed eros augue, ultrices quis neque eget, bibendum convallis lorem. Etiam luctus finibus consequat.
</Run><LineBreak />
<Run>Etiam viverra scelerisque risus et scelerisque. Praesent ipsum tellus, iaculis in augue quis, pharetra commodo dolor. In risus nisi, eleifend ut volutpat in, viverra a arcu. Vestibulum congue purus risus, rhoncus viverra ligula tempor in. Pellentesque ornare tempor ex, cursus suscipit mi dignissim a. Vivamus pulvinar at purus et feugiat. Donec consectetur malesuada consequat. Vestibulum est diam, sagittis in vehicula tempor, euismod ac ex. Nam in purus aliquet, ultricies ante at, tempus arcu. Praesent at orci accumsan, tincidunt leo eget, rhoncus nunc. Aenean eget fermentum justo.</Run><LineBreak />
<Run>
Nullam tincidunt tempor velit, eu commodo ipsum rhoncus sagittis. Nunc vel tortor nec ante pulvinar sagittis. Nullam eget sagittis orci. Nunc tristique nibh eu lacinia finibus. Donec eu volutpat nisi, eget fermentum quam. Aenean ut interdum dolor. Nunc nibh eros, aliquet eget augue tincidunt, congue tincidunt nisl.
</Run><LineBreak />
<Run>
Cras bibendum varius iaculis. In et rhoncus tortor. Nullam ac malesuada urna, eu gravida ante. Nam dictum consectetur leo. Quisque sem orci, auctor at ornare vulputate, maximus in enim. In in libero ac lorem tristique vulputate a vitae risus. Fusce vitae rhoncus lectus, quis lobortis tortor. Sed suscipit auctor lorem, eget finibus leo elementum et. Sed lobortis felis lectus, quis malesuada lacus sodales sed. Nulla vitae turpis id tellus convallis vulputate sed eu metus.
</Run>
</TextBlock>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<StackPanel
Margin="0,35,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock
Grid.Row="0"
FontSize="14"
TextWrapping="WrapWithOverflow">
<Run>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque luctus malesuada mollis. Ut placerat dolor ac ligula consectetur, aliquam viverra odio dignissim. Donec in finibus tortor. Suspendisse eget ipsum vel arcu feugiat porttitor. Mauris et arcu pretium ipsum posuere tincidunt at a magna. Nullam finibus, arcu sit amet convallis sollicitudin, odio nisi efficitur mauris, quis aliquam dolor velit ac est. Integer quis ante velit. Etiam tincidunt, purus ut tempus auctor, sem augue congue urna, a vulputate mauris tortor a enim. Sed eros augue, ultrices quis neque eget, bibendum convallis lorem. Etiam luctus finibus consequat.
</Run><LineBreak />
<Run>Etiam viverra scelerisque risus et scelerisque. Praesent ipsum tellus, iaculis in augue quis, pharetra commodo dolor. In risus nisi, eleifend ut volutpat in, viverra a arcu. Vestibulum congue purus risus, rhoncus viverra ligula tempor in. Pellentesque ornare tempor ex, cursus suscipit mi dignissim a. Vivamus pulvinar at purus et feugiat. Donec consectetur malesuada consequat. Vestibulum est diam, sagittis in vehicula tempor, euismod ac ex. Nam in purus aliquet, ultricies ante at, tempus arcu. Praesent at orci accumsan, tincidunt leo eget, rhoncus nunc. Aenean eget fermentum justo.</Run><LineBreak />
<Run>
Nullam tincidunt tempor velit, eu commodo ipsum rhoncus sagittis. Nunc vel tortor nec ante pulvinar sagittis. Nullam eget sagittis orci. Nunc tristique nibh eu lacinia finibus. Donec eu volutpat nisi, eget fermentum quam. Aenean ut interdum dolor. Nunc nibh eros, aliquet eget augue tincidunt, congue tincidunt nisl.
</Run><LineBreak />
<Run>
Cras bibendum varius iaculis. In et rhoncus tortor. Nullam ac malesuada urna, eu gravida ante. Nam dictum consectetur leo. Quisque sem orci, auctor at ornare vulputate, maximus in enim. In in libero ac lorem tristique vulputate a vitae risus. Fusce vitae rhoncus lectus, quis lobortis tortor. Sed suscipit auctor lorem, eget finibus leo elementum et. Sed lobortis felis lectus, quis malesuada lacus sodales sed. Nulla vitae turpis id tellus convallis vulputate sed eu metus.
</Run>
</TextBlock>

<StackPanel
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center">

<TextBlock
x:Name="TextBlock"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="Red"
Text="You must accept these terms of use to continue"
Visibility="Collapsed" />
<TextBlock
x:Name="TextBlock"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="Red"
Text="You must accept these terms of use to continue"
Visibility="Collapsed" />

<CheckBox
x:Name="CheckBox"
Margin="0,15,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Content="Agree"
FontSize="16" />
</StackPanel>
<CheckBox
x:Name="CheckBox"
Margin="0,15,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Content="Agree"
FontSize="16" />
</StackPanel>
</Grid>
</ui:ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

using System.Windows;
using Wpf.Ui.Controls;
using Wpf.Ui.Controls.ContentDialogControl;
using Wpf.Ui.Gallery.Controls;
using Wpf.Ui.Gallery.Views.Windows;

namespace Wpf.Ui.Gallery.ViewModels.Pages.DialogsAndFlyouts;

Expand All @@ -26,15 +23,14 @@ public ContentDialogViewModel(IContentDialogService contentDialogService)
[RelayCommand]
private async Task OnShowDialog(object content)
{
var dialog = _contentDialogService.CreateDialog();
dialog.Title = "Save your work?";
dialog.Content = content;
dialog.PrimaryButtonText = "Save";
dialog.SecondaryButtonText = "Don't Save";
dialog.CloseButtonText = "Cancel";
dialog.DefaultButton = ContentDialogButton.Primary;

var result = await dialog.ShowAsync();
var result = await _contentDialogService.ShowSimpleDialogAsync(new SimpleContentDialogCreateOptions()
{
Title = "Save your work?",
Content = content,
PrimaryButtonText = "Save",
SecondaryButtonText = "Don't Save",
CloseButtonText = "Cancel",
});

DialogResultText = result switch
{
Expand Down
25 changes: 22 additions & 3 deletions src/Wpf.Ui/Contracts/IContentDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.

using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using Wpf.Ui.Controls;
using Wpf.Ui.Controls.ContentDialogControl;

namespace Wpf.Ui.Contracts;
Expand All @@ -27,8 +28,26 @@ public interface IContentDialogService
ContentPresenter GetContentPresenter();

/// <summary>
/// Creates a new <see cref="ContentDialog"/>
/// Shows alert dialog.
/// </summary>
/// <returns></returns>
ContentDialog CreateDialog();
Task<ContentDialogResult> ShowAlertAsync(string title, string message, string closeButtonText, CancellationToken cancellationToken = default);

/// <summary>
/// Shows simple dialog
/// </summary>
/// <param name="options"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<ContentDialogResult> ShowSimpleDialogAsync(SimpleContentDialogCreateOptions options, CancellationToken cancellationToken = default);
}

public class SimpleContentDialogCreateOptions
{
public required string Title { get; set; }
public required object Content { get; set; }
public required string CloseButtonText { get; set; }

public string PrimaryButtonText { get; set; } = string.Empty;
public string SecondaryButtonText { get; set; } = string.Empty;
}
Loading