summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-08-30 12:12:27 -0600
committerJason Smith <jason.smith@xamarin.com>2016-08-30 11:12:27 -0700
commit1b7250167ff027bbd5ce3d2950a3e3495a13a5f7 (patch)
treebc219a8dada47527b2252fb7a07f8158b6f24701 /Xamarin.Forms.Platform.WinRT
parent0bc22bda64afedbca09416cdccc77ce4ddbe522d (diff)
downloadxamarin-forms-1b7250167ff027bbd5ce3d2950a3e3495a13a5f7.tar.gz
xamarin-forms-1b7250167ff027bbd5ce3d2950a3e3495a13a5f7.tar.bz2
xamarin-forms-1b7250167ff027bbd5ce3d2950a3e3495a13a5f7.zip
Use character truncation in Windows (#321)
Change layout order ViewCells on Windows to correct label length layout issues Add extra layout pass on ViewCell load to make cells without margins visible
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r--Xamarin.Forms.Platform.WinRT/LabelRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs31
2 files changed, 22 insertions, 11 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/LabelRenderer.cs b/Xamarin.Forms.Platform.WinRT/LabelRenderer.cs
index cb33cde9..1f2f861d 100644
--- a/Xamarin.Forms.Platform.WinRT/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/LabelRenderer.cs
@@ -165,7 +165,7 @@ namespace Xamarin.Forms.Platform.WinRT
textBlock.TextWrapping = TextWrapping.NoWrap;
break;
case LineBreakMode.TailTruncation:
- textBlock.TextTrimming = TextTrimming.WordEllipsis;
+ textBlock.TextTrimming = TextTrimming.CharacterEllipsis;
textBlock.TextWrapping = TextWrapping.NoWrap;
break;
case LineBreakMode.MiddleTruncation:
diff --git a/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs b/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs
index 38950522..3d5906dc 100644
--- a/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs
+++ b/Xamarin.Forms.Platform.WinRT/ViewToRendererConverter.cs
@@ -2,6 +2,7 @@
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
+using Xamarin.Forms.Internals;
#if WINDOWS_UWP
@@ -41,6 +42,8 @@ namespace Xamarin.Forms.Platform.WinRT
{
readonly View _view;
+ FrameworkElement FrameworkElement => Content as FrameworkElement;
+
public WrapperControl(View view)
{
_view = view;
@@ -54,9 +57,17 @@ namespace Xamarin.Forms.Platform.WinRT
Content = renderer.ContainerElement;
// make sure we re-measure once the template is applied
- FrameworkElement frameworkElement = renderer.ContainerElement;
- if (frameworkElement != null)
- frameworkElement.Loaded += (sender, args) => InvalidateMeasure();
+ if (FrameworkElement != null)
+ {
+ FrameworkElement.Loaded += (sender, args) =>
+ {
+ // If the view is a layout (stacklayout, grid, etc) we need to trigger a layout pass
+ // with all the controls in a consistent native state (i.e., loaded) so they'll actually
+ // have Bounds set
+ (_view as Layout)?.ForceLayout();
+ InvalidateMeasure();
+ };
+ }
}
protected override Windows.Foundation.Size ArrangeOverride(Windows.Foundation.Size finalSize)
@@ -65,18 +76,15 @@ namespace Xamarin.Forms.Platform.WinRT
Layout.LayoutChildIntoBoundingRegion(_view, new Rectangle(0, 0, finalSize.Width, finalSize.Height));
_view.IsInNativeLayout = false;
- var content = Content as FrameworkElement;
- content.Arrange(new Rect(_view.X, _view.Y, _view.Width, _view.Height));
+ FrameworkElement?.Arrange(new Rect(_view.X, _view.Y, _view.Width, _view.Height));
return finalSize;
}
protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize)
{
- var content = Content as FrameworkElement;
- content?.Measure(availableSize);
Size request = _view.Measure(availableSize.Width, availableSize.Height, MeasureFlags.IncludeMargins).Request;
-
- var result = new Windows.Foundation.Size();
+
+ Windows.Foundation.Size result;
if (_view.HorizontalOptions.Alignment == LayoutAlignment.Fill && !double.IsInfinity(availableSize.Width) && availableSize.Width != 0)
{
result = new Windows.Foundation.Size(availableSize.Width, request.Height);
@@ -86,7 +94,10 @@ namespace Xamarin.Forms.Platform.WinRT
result = new Windows.Foundation.Size(request.Width, request.Height);
}
- _view.Layout(new Rectangle(0, 0, result.Width, result.Width));
+ _view.Layout(new Rectangle(0, 0, result.Width, result.Height));
+
+ FrameworkElement?.Measure(availableSize);
+
return result;
}