英文:
Switch control appears faded when not toggedon by default
问题
我在我的一个表单上有一堆数据绑定的开关:
<Label Grid.Column="0" Grid.Row="0" Text="选项 1" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="0" IsToggled="{Binding Options.One, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="1" Text="选项 2" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="1" IsToggled="{Binding Options.Two, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="2" Text="选项 3" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="2" IsToggled="{Binding Options.Three, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="3" Text="选项 4" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="3" IsToggled="{Binding Options.Four, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="4" Text="选项 5" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="4" IsToggled="{Binding Options.Five, Mode=TwoWay}"/>
功能上,这个工作得如预期。但是,我在UI方面看到了一些奇怪的现象...
如果绑定源在页面显示时提供了"true",那么开关控件看起来正如我所期望的那样 - 明亮而美观,无论你多少次切换它。
然而,如果绑定源提供了"false",然后你将开关切换到"on",那么它看起来会变得模糊 - 几乎像是被禁用了,尽管它是完全可用的。
正如我所说,这背后的功能是正常的 - 我的绑定属性被正确更新 - 只是视觉外观让我感到不适 :)
在这张图片中,所有奇数选项的绑定属性都设置为"true",而偶数选项的绑定属性都设置为"false"。
然后我切换了每个选项几次。
英文:
I've got a bunch of databound switches on one of my forms:
<Label Grid.Column="0" Grid.Row="0" Text="option 1" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="0" IsToggled="{Binding Options.One, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="1" Text="option 2" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="1" IsToggled="{Binding Options.Two, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="2" Text="option 3" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="2" IsToggled="{Binding Options.Three, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="3" Text="option 4" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="3" IsToggled="{Binding Options.Four, Mode=TwoWay}" HorizontalOptions="End"/>
<Label Grid.Column="0" Grid.Row="4" Text="option 5" VerticalOptions="Center" FontSize="Large" HorizontalOptions="Start"/>
<Switch Grid.Column="1" Grid.Row="4" IsToggled="{Binding Options.Five, Mode=TwoWay}"/>
Functionally, this is working as expected. However, I'm seeing a bit of an oddity with the UI...
If the binding source provides "true" at the point the page is displayed, the switch control looks as I'd expect - nice and bright, no matter how many times I toggle it.
However, if the binding source provides "false", and you then toggle the switch to "on", then it looks faded - almost as if it's disabled, even though its fully usable.
As I say, the functionality behind this works - my bound properties are getting updated correctly - it's just the visual appearance that's bugging me
In this picture, all the bound properties for odd-numbered options was set to "true", whereas the bound properties for the even-numbered ones were set "false".
I've then toggled each option off and on a few times:
答案1
得分: 2
这是在XF 4.2.0中引入的bug。要解决它,您需要降级到低于4.2.0的版本,或者升级到Xamarin.Forms 4.4.0.991210-pre2(4.4.0预览版2)或更高版本,其中修复了bug。
如果可能的话,我建议升级到XF 4.4.0稳定版。
英文:
This was a bug introduced in XF 4.2.0. To resolve it, you'll need to downgrade to something lower than 4.2.0 or upgrade to Xamarin.Forms 4.4.0.991210-pre2 (4.4.0 Pre Release 2) or higher where the bug was fixed.
If possible, my recommendation would be to upgrade to XF 4.4.0 stable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论