gpt4 book ai didi

how to change the picker outer border color .net maui(如何更改选取器外边框颜色.Net Maui)

转载 作者:bug小助手 更新时间:2023-10-24 19:30:04 46 4
gpt4 key购买 nike



Hey how can i change the ugly outer borders on win ui .net maui picker? Is there any way to disable it? Or maybe change the color?

嘿,我怎么才能改变Win UI.Net Maui Picker上难看的外部边框呢?有什么办法可以禁用它吗?或者换个颜色?


Also what is this weird bug when you hover over the picker the texts change colors?

还有,当你将鼠标悬停在选取器上,文本会改变颜色时,这个奇怪的错误是什么?


更多回答

Out of the box, those controls are very hard to customize. You can always try to write your own control, or write bunch of platform specific code to customize the way they look. There are some answers already "how to customize picker". I prefer to live with the ugly borders.

开箱即用,这些控件很难定制。您可以尝试编写自己的控件,或者编写一组特定于平台的代码来定制它们的外观。“如何定制Picker”已经有了一些答案。我更喜欢生活在丑陋的边界中。

优秀答案推荐

The picker's windows natvie control is combobox. So you can use the handler to disable the border:

选取器的窗口Natvie控件是组合框。因此,您可以使用处理程序禁用边框:


public App()
      {
            InitializeComponent();

            MainPage = new AppShell();
Microsoft.Maui.Handlers.PickerHandler.Mapper.AppendToMapping(nameof(Picker), (handler, view) =>
{
#if WINDOWS
var combobox = handler.PlatformView;
combobox.BorderBrush = null;
combobox.BorderThickness = new Microsoft.UI.Xaml.Thickness(0);
#endif
});
}

Or you can change its color by change the windows native combobox style. Just add the following code to the \Platforms\Windows\App.xaml:

或者,您可以通过更改Windows本机组合框样式来更改其颜色。只需将以下代码添加到\Platels\Windows\App.xaml:


<maui:MauiWinUIApplication
x:Class="MauiAppTest.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:MauiAppTest.WinUI">
<maui:MauiWinUIApplication.Resources>
<ResourceDictionary>
<SolidColorBrush x:Key="ComboBoxBorderBrush" Color="#Ff0000" />
<SolidColorBrush x:Key="ComboBoxBorderBrushPointerOver" Color="#Ff0000" />
<SolidColorBrush x:Key="ComboBoxBorderBrushPressed" Color="#Ff0000" />
</ResourceDictionary>
</maui:MauiWinUIApplication.Resources>
</maui:MauiWinUIApplication>

But I can't reproduce the problem you said about the text color changed. You can check the default style of the combobox.

但我无法重现您所说的文本颜色更改的问题。您可以选中组合框的默认样式。


更多回答

hey thank you so much. do you know how to change the arrow down color? or how to disable it?

嘿,非常感谢你。你知道怎么改变向下箭头的颜色吗?或者如何禁用它?

You can hide it by set the color as transparent. Such as <SolidColorBrush x:Key="ComboBoxDropDownGlyphForeground" Color="#000000" />. @FardinFarnezhad

您可以通过将颜色设置为透明来隐藏它。例如。@FardinFarnezhad

And did this answer your new question on the SO? Or did you want make the picker like an entry for all the platforms? @FardinFarnezhad

这回答了你关于SO的新问题了吗?还是想让选取器成为所有平台的条目?@FardinFarnezhad

it actually did but i still encountered wierd bugs so i decided to hide the picker behind an entry untill the bugs get resolved i think this is the best way but thank you so much your answer actually opened my eyes. sorry for bothering you .

实际上是这样的,但我仍然遇到了奇怪的错误,所以我决定将选择器隐藏在一个条目后面,直到错误得到解决为止。我认为这是最好的方法,但非常感谢您的回答让我大开眼界。对不起,打扰你了。

You are welcome and I had a mistake. The transparent color should be #0000 not #000000. @FardinFarnezhad

不客气,我弄错了。透明颜色应该是#000000,而不是#0000。@FardinFarnezhad

46 4 0