Skip to content

Set size of DashedLine explicitly#1772

Merged
Keboo merged 5 commits into
MaterialDesignInXAML:masterfrom
greuelpirat:1735-dashed-line-size
Apr 27, 2020
Merged

Set size of DashedLine explicitly#1772
Keboo merged 5 commits into
MaterialDesignInXAML:masterfrom
greuelpirat:1735-dashed-line-size

Conversation

@greuelpirat
Copy link
Copy Markdown
Contributor

@greuelpirat greuelpirat commented Apr 26, 2020

Resolves #1735

I found that this trigger caused the high CPU usage:

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="false" />
<Condition Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="False" />
<Condition Property="wpf:TextFieldAssist.HasFilledTextField" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="DashedLine" Property="Visibility" Value="Visible" />
</MultiTrigger>

So I guess that the disabled DashedLine (disabled, because of placement in RightDrawerContent) had no fix size. So I set it:

Height="{Binding BorderThickness.Bottom, ElementName=border, Converter={StaticResource DivisionMathConverter}, ConverterParameter=0.75}"
Width="{Binding ActualWidth, ElementName=border}"

and the CPU usage was gone.

Beside MaterialDesignTheme.TextBox.xaml I updated other controls, since they seems to have a similar DashedLine

  • MaterialDesignTheme.ComboBox.xaml
  • MaterialDesignTheme.DatePicker.xaml
  • MaterialDesignTheme.PasswordBox.xaml
  • MaterialDesignTheme.TimePicker.xaml

PS: I also updated the Fields.xaml in demo app, where I forgot the disabled fields during #1749 :-(

Copy link
Copy Markdown
Member

@Keboo Keboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great working tracking this down. Thank you

Grid.ColumnSpan="2"
Grid.Column="0"
VerticalAlignment="Bottom"
Height="{Binding BorderThickness.Bottom, ElementName=toggleButton, Converter={StaticResource DivisionMathConverter}, ConverterParameter=0.75}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this works, binding to BorderTickness.Bottom exposes a memory leak (the Binding leak section) because BorderThickeness is a just a Thickness struct. It actually appears that we have the same bug on the StrokeThickness as well. I would propose the following fixes:

  1. Since it looks like we are trying to keep these properties in sync, why not simply bind the Height to the StrokeHeight property. {Binding StrokeHeight, RelativeSource={RelativeSource Self}}
  2. Rather than binding through the BorderThickness property, lets create a value converter that takes in the BorderThickness directly, and applies the appropriate math we need for this line. I would propose that this converter be made internal for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points. I have implemented those. 👍

@Keboo Keboo added this to the 3.1.1 milestone Apr 26, 2020
@Keboo Keboo merged commit ef43114 into MaterialDesignInXAML:master Apr 27, 2020
@greuelpirat greuelpirat deleted the 1735-dashed-line-size branch May 4, 2020 16:24
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.

DrawerHost crash when there's a textbox inside

2 participants