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

Set size of DashedLine explicitly #1772

Merged
merged 5 commits into from
Apr 27, 2020

Conversation

greuelpirat
Copy link
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
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

@@ -486,6 +486,8 @@
Grid.ColumnSpan="2"
Grid.Column="0"
VerticalAlignment="Bottom"
Height="{Binding BorderThickness.Bottom, ElementName=toggleButton, Converter={StaticResource DivisionMathConverter}, ConverterParameter=0.75}"
Copy link
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
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