private void InitializeProperty(ListProperty property) { IsReadOnly = !property.Editable; if (IsReadOnly) { Background = Theme.TextBackgroundDisabled; } PasswordCharAttribute passwordCharAttribute = property.PropertyInfo.GetCustomAttribute <PasswordCharAttribute>(); if (passwordCharAttribute != null) { PasswordChar = passwordCharAttribute.Character; } SetWatermark(property); if (property.PropertyInfo.GetCustomAttribute <WordWrapAttribute>() != null) { TextWrapping = TextWrapping.Wrap; AcceptsReturn = true; MaxHeight = 500; } AcceptsReturnAttribute acceptsReturnAttribute = property.PropertyInfo.GetCustomAttribute <AcceptsReturnAttribute>(); if (acceptsReturnAttribute != null) { AcceptsReturn = acceptsReturnAttribute.Allow; } MaxWidth = TabControlParams.ControlMaxWidth; BindProperty(property); AvaloniaUtils.AddContextMenu(this); // Custom menu to handle ReadOnly items better }
private void InitializeComponent() { Background = Theme.TextBackgroundBrush; BorderBrush = Brushes.Black; BorderThickness = new Thickness(1); HorizontalAlignment = HorizontalAlignment.Stretch; VerticalAlignment = VerticalAlignment.Top; MinWidth = 50; MaxWidth = TabControlParams.ControlMaxWidth; Margin = new Thickness(6); Padding = new Thickness(6, 3); TextBlock = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Foreground = Theme.TitleForeground, TextWrapping = TextWrapping.Wrap, FontSize = 14, Text = Text, }; AvaloniaUtils.AddContextMenu(TextBlock); var scrollViewer = new ScrollViewer() { Content = TextBlock, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, BorderThickness = new Thickness(2), // doesn't work BorderBrush = Brushes.Black, Padding = new Thickness(10), }; Child = scrollViewer; }