Git Product home page Git Product logo

Comments (4)

github-actions avatar github-actions commented on September 26, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

from microsoft-ui-xaml.

YourOrdinaryCat avatar YourOrdinaryCat commented on September 26, 2024

Setting the placeholder text to the current selection works as well - when the popup opens, the width seems to be measured based on the placeholder. Why ComboBox behaves this way is beyond me, but that's the workaround I'll be using for now.

from microsoft-ui-xaml.

0x5bfa avatar 0x5bfa commented on September 26, 2024

For anyone suffering from this behavior (original credit: Discord user @metrorail):

// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.Foundation;

namespace Files.App.UserControls
{
	public class ComboBoxEx : ComboBox
	{
		double _cachedWidth;

		protected override void OnDropDownOpened(object e)
		{
			Width = _cachedWidth;

			base.OnDropDownOpened(e);
		}

		protected override void OnDropDownClosed(object e)
		{
			Width = double.NaN;

			base.OnDropDownClosed(e);
		}

		protected override Size MeasureOverride(Size availableSize)
		{
			var baseSize = base.MeasureOverride(availableSize);

			if (baseSize.Width != 64)
				_cachedWidth = baseSize.Width;

			return baseSize;
		}
	}
}

from microsoft-ui-xaml.

kmahone avatar kmahone commented on September 26, 2024

What is happening here is that when the combobox is opened, the currently selected item is moved into the popup menu so that it can be shown there. But since it was removed from the main part of the ComboBox, that can cause the ComboBox to re-layout at a smaller size and so you get this jarring behavior.

ComboBox should maintain its width when it opens its popup to prevent this issue from happening. The "ComboBoxEx" workaround proposed does that.

Another workaround here would be to set a MinWidth on the ComboBox so that it maintains its size regardless of the selected item.

from microsoft-ui-xaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.