-
Notifications
You must be signed in to change notification settings - Fork 677
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
Unable to set width of ContentDialog #424
Comments
Good bug. I believe this is because ContentDialog is a FrameworkElement but it moves its content to a popup so the layout-related properties don't take effect. We can probably make the *Width/*Height properties work. |
This is impacting me as well, it would be great to get a fix. :) |
Hi guys, I note the tag "needs-winui-3" has been added to this. Is there a work around that would allow me to increase the size of a content dialog? |
@knightmeister, there's a resource in generic.xaml that controls ContentDialog's width: <x:Double x:Key="ContentDialogMaxWidth">548</x:Double> You should be able to set this double to a larger value within your App.xaml resources. Edit: reread your original post and this is exactly the resource you're noting doesn't work. I'm not sure why that is. I'm not aware of any other workarounds. What happens when you only change dialog.MinWidth = this.ActualWidth * .8;
dialog.Width = this.ActualWidth * .8;
dialog.MaxWidth = this.ActualWidth * .8; ? |
It would also be great if there is a way to set width based on the main windows width breakpoints. |
I tried that, but it didn't work as well. |
So what we can say is that for larger payloads it is back to a in-page Grid whose Visibility gets turned on and off, or maybe a Flyout? Oh dear, because this behavior has been unchanged for more than a year now... |
Setting |
does not get me either to the desired width. |
Is there a timeline to overhaul the
|
Just as a spin-off comment , for individuals this issue becomes exigent, may want to get a little familiar with the respective Infragistics control. |
Any updates? 2022 is coming but the ContentDialog (the rectangle with content) still can't measure width by content. |
Pull request #5872 |
The width of the ContentDialog does not change, only moves to the left. Helps only set ContentDialogMaxWidth |
I'm still getting this issue, unable to set width, max-width, and padding properties of content dialog. Please fix this bug, ContentDialog has some good styles but these kinds of restrictions make it unusable. |
Yes, this is still an issue for me too. Adding a line like <x:Double x:Key="ContentDialogMaxWidth">1600</x:Double> to your App.xaml section is a workaround and dialog will set its width to the contents as long as contents are within that value. However, the dialog buttons at bottom become inordinately wide along with expanding to content width. A real solution is still needed. |
Is this still on the radar, to have a functioning modal solution for a windowing operating system? It is absolutely insane that the implementation of ContentDialog is so broken that you cannot properly resize or reposition them. The current implementation works fine for a message box replacement but is absolutely unworkable for any other form of modal task (preferences window, data entry, etc). I'm hopeful that this can be addressed soon. |
I tried several suggestions and the only thing that worked for me was setting the above mentioned double key in the resources of the content dialog itself. (It did not work in the App.xaml for me).
|
I wonder if it can be scheduled anywhere on the roadmap in 2022 : https://github.com/microsoft/WindowsAppSDK/blob/main/docs/roadmap.md The version 1.1 does not seem to aim fixing this
|
+1 for me too. |
Hi everyone. I also struggled with this a while ago and i don't remember where i saw this but this problem has been "solved" a while ago. This has to do with the order of resource loading.
problem is when you put your
Notice we now import the namespace |
I was struggling with this myself for a while, the recommended solution provided by @jamorais worked for me. Thank you! |
@jamorais does it work for an unpackaged or packaged application ? for me unpackaged and takes no effect. |
@sigmarsson, never tried it on unpackaged.... |
Hey @sigmarsson , |
@jamorais Thank you much for your time and effort. |
FYI, this is fixed in Windows App SDK 1.1.4 You can now go back to using this as you typically would: <Application
x:Class="App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary>
<x:Double x:Key="ContentDialogMaxWidth">1000</x:Double>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application> |
An upgrade to 1.1.4 did not solve the problem. I really do not get how this all works hopefully someone can help me and we can solve this. What do we try to achieve by wrapping the Resource directories in this Why do I need to state Thanks in advance guys! |
The only way we have found to change the ContentDialog width is overriding the default control template:
|
My workaround as blow, instead of changing the width of the ContentDialog, I changed the with of the root element in the dialog. <ContentDialog x:Class="Test.Views.Dialogs.TestDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<ContentDialog.Resources>
<Thickness x:Key="ContentDialogPadding">5,5,5,5</Thickness>
<x:Double x:Key="ContentDialogMaxWidth">2000</x:Double>
<x:Double x:Key="ContentDialogMaxHeight">2000</x:Double>
</ContentDialog.Resources>
<Grid x:Name="container" VerticalAlignment="Stretch"> public TestDialog()
{
InitializeComponent();
container.Width = App.StartupWindow.Bounds.Width * .8;
container.Height = App.StartupWindow.Bounds.Height * .7;
} |
ITNOA Any update?! this problem exist in latest WinUI 3 too. |
ContentDialogMaxWidth works for me (Windows 10 22H2) since at least 1.1.0 |
hahh,i test a new method, is works for me
|
Thank you SO much for this. This problem was driving me crazy. Works flawlessly in WinUI3, SDK 1.5. |
Any updates on this issue? I managed to make mine work using the above mentioned workarounds but I really would like to see this bug getting fixed. |
I can't get this to work in a UWP project, if I use: <ContentDialog.Resources> to change the maxwidth and define the ContentDialog in the xaml, it looks correct in the designer view but when I launch the app is just reverts back to the default maxwidth. I don't understand this. update: |
Describe the bug
Using the properties
MinWidth
,MaxWidth
andWidth
have no effect on the width of the ContentDialog but break the ability to resize the window and keep the ContentDialog centered. There are numerous questions on StackOverflow about setting the content dialog width. The solution is always to change theContentDialogMaxWidth
in App.xaml but even setting that does not work as expected.Steps to reproduce the bug
Add a button to a page and use the following event handler:
When updating the
ContentDialogMaxWidth
:Expected behavior
I would expect the following behaviour:
ContentDialogMaxWidth
) The dialog consumes 80% of the window sizeActual behaviour
ContentDialogMaxWidth
, in conjunction with MinWidth/MaxWidth/Width 80% of the width is used however the dialog is not horizontally centered and does not recenter as the dialog is resized.Screenshots
Screenshot 1: None of MinWidth/MaxWidth/Width are set:
The following screenshots have MinWidth/MaxWidth and Width set to this.ActualWidth * .8
Screenshot 2: ContentDialog is no longer centered:
Screenshot 3: ContentDialog is not repositioned on resize:
The following screenshots have MinWidth/MaxWidth and Width set to this.ActualWidth * .8 with ContentDialogMaxWidth = 9999
Version Info
1809 using the Windows inbuilt controls
NuGet package version:
N/A
The text was updated successfully, but these errors were encountered: