Removing LineBreakMode support from WindowsResourcesProvider (#4024)
* Repro test page for 3979 * Removes LineBreakMode support from WindowsResourcesProvider as it is inconsistent with other platforms and caused issues when setting Span style to the default Device Styles
This commit is contained in:
Родитель
a3901827a4
Коммит
660613a9ba
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<controls:TestContentPage
|
||||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Xamarin.Forms.Controls.Issues.Issue3979">
|
||||
<ContentPage.Content>
|
||||
<StackLayout>
|
||||
<Label LineBreakMode="WordWrap">Clicking the button sets one of the spans in the following label to Device.Styles.BodyStyle. This test succeeds if clicking the button does not cause exception.</Label>
|
||||
<Label>
|
||||
<Label.FormattedText>
|
||||
<FormattedString>
|
||||
<Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" />
|
||||
<Span Text="default, " x:Name="TargetSpan">
|
||||
<Span.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding TapCommand}" />
|
||||
</Span.GestureRecognizers>
|
||||
</Span>
|
||||
<Span Text="italic small." FontAttributes="Italic" FontSize="Small" />
|
||||
</FormattedString>
|
||||
</Label.FormattedText>
|
||||
</Label>
|
||||
<Button Clicked="Button_OnClicked" Text="Set style" />
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</controls:TestContentPage>
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 3979, "Issue Description", PlatformAffected.UWP)]
|
||||
public partial class Issue3979 : TestContentPage // or TestMasterDetailPage, etc ...
|
||||
{
|
||||
public Issue3979()
|
||||
{
|
||||
#if APP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Button_OnClicked(object sender, EventArgs e)
|
||||
{
|
||||
TargetSpan.Style = Device.Styles.BodyStyle;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -395,6 +395,10 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue3541.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue3840.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue3913.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue3979.xaml.cs">
|
||||
<DependentUpon>Issue3979.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)LegacyComponents\NonAppCompatSwitch.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)MapsModalCrash.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ModalActivityIndicatorTest.cs" />
|
||||
|
@ -1007,4 +1011,10 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue3979.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -34,8 +34,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
|
||||
formsStyle.Setters.Add(Label.FontSizeProperty, prototype.FontSize);
|
||||
formsStyle.Setters.Add(Label.FontFamilyProperty, prototype.FontFamily.Source);
|
||||
formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(prototype.FontWeight));
|
||||
formsStyle.Setters.Add(Label.LineBreakModeProperty, ToLineBreakMode(prototype.TextWrapping));
|
||||
formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(prototype.FontWeight));
|
||||
|
||||
return formsStyle;
|
||||
}
|
||||
|
@ -50,19 +49,5 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
|
||||
return FontAttributes.None;
|
||||
}
|
||||
|
||||
static LineBreakMode ToLineBreakMode(TextWrapping value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case TextWrapping.Wrap:
|
||||
return LineBreakMode.CharacterWrap;
|
||||
case TextWrapping.WrapWholeWords:
|
||||
return LineBreakMode.WordWrap;
|
||||
default:
|
||||
case TextWrapping.NoWrap:
|
||||
return LineBreakMode.NoWrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче