Example #1
0
        private void SetContentTemplateRootToPlaceholder()
        {
            if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
            {
                this.Log().DebugFormat("No ContentTemplate was specified for {0} and content is not a UIView, defaulting to TextBlock.", GetType().Name);
            }

            var textBlock = new ImplicitTextBlock(this);

            void setBinding(DependencyProperty property, string path)
            => textBlock.SetBinding(
                property,
                new Binding {
                Path   = new PropertyPath(path),
                Source = this,
                Mode   = BindingMode.OneWay
            }
                );

            setBinding(TextBlock.TextProperty, nameof(Content));
            setBinding(TextBlock.HorizontalAlignmentProperty, nameof(HorizontalContentAlignment));
            setBinding(TextBlock.VerticalAlignmentProperty, nameof(VerticalContentAlignment));
            setBinding(TextBlock.TextWrappingProperty, nameof(TextWrapping));
            setBinding(TextBlock.MaxLinesProperty, nameof(MaxLines));
            setBinding(TextBlock.TextAlignmentProperty, nameof(TextAlignment));

            ContentTemplateRoot = textBlock;
        }
Example #2
0
        private void SetContentTemplateRootToPlaceholder()
        {
            if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
            {
                this.Log().DebugFormat("No ContentTemplate was specified for {0} and content is not a UIView, defaulting to TextBlock.", GetType().Name);
            }

            ContentTemplateRoot = new ImplicitTextBlock()
                                  .Binding("Text", "")
                                  .Binding("HorizontalAlignment", new Binding {
                Path = "HorizontalContentAlignment", Source = this, Mode = BindingMode.OneWay
            })
                                  .Binding("VerticalAlignment", new Binding {
                Path = "VerticalContentAlignment", Source = this, Mode = BindingMode.OneWay
            });
        }