Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TextBox instead of TextBlock for displaying read only property #1540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Nfactor26
Copy link

Issue Description

  1. TextBlockEditor : TypeEditor is used in PropertyGrid for displaying readonly properties.
    However, TextBlock control in WPF doesn't allow to override it's Template using a style.
  2. Margin is set to (5,0,0,0) from inside SetControlProperties() of TextBlockEditor which takes precedence over any margin applied from style.

Changes

  1. Created a new ReadOnlyTextBoxEditor which uses TextBox to display readonly property
  2. The default style overrides control template of textbox such that it uses a TextBlock with TextTrimming="CharacterEllipsis" and Margin="5,0,0,0" similar to what TextBlockEditor was using.
  3. Updated TextBlockEditor initialization at different places to intialize ReadOnlyTextBoxEditor instead.

**Impact on existing users **

  1. Those using default styles won't notice any difference in UI since TextBlock will be used to display readonly property
  2. Those who have customized style for TextBlockEditor will have to create a new style for ReadOnlyTextBoxEditor instead.

** Benefit **
Users will now be able to provide a custom control template in styles for displaying their readonly property which was not possible before with a TextBlock.

…since TextBlock doesn't support control templates

TextBlock WPF control doesn't support overriding it's control template from styles. Instead use a TextBox control with a default style which  uses TextBlock as control template instead so that style can be customized as per requirement.
@XceedBoucherS
Copy link
Collaborator

Hi,
You are right, TextBlockEditor.SetControlProperties() modify the Margin and TextTrimming of the editor so a style can't override those values. But if we remove those 2 properties from TextBlockEditor.SetControlProperties() and set them in the style targeting PropertyGridEditorTextBlock (from Aero2.NormalColor.xaml), it fixes the issue.

A user then simply needs to do this in is xaml in order to modify the style:
<Window.Resources> <Style TargetType="{x:Type xctk:PropertyGridEditorTextBlock}"> </Style> </Window.Resources>

This will be fixed in v3.9.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants