Skip to content

Commit a7e42b4

Browse files
committed
Optimized PathTrimmingTextblock with input from Forum in referenced codeproject article.
1 parent b643dbb commit a7e42b4

File tree

4 files changed

+123
-195
lines changed

4 files changed

+123
-195
lines changed

source/MRULib/Controls/PathTrimmingFileHyperlink.xaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
xmlns:ctrl="clr-namespace:MRULib.Controls"
1111
xmlns:reskeys="clr-namespace:MRULib.Themes"
1212
>
13-
<!--
14-
!!! NOT Using a Grid here because the PathTrimmingTextBlock looks for a parent Grid
15-
!!! to compute its correct size. So, the complete control should be placed inside a Grid
16-
!!! to make sure measuring works as expected.
17-
-->
18-
<!--UserControl.ContextMenu>
13+
<!--UserControl.ContextMenu>
1914
<ContextMenu>
2015
<MenuItem Header="Copy Url to Clipboard"
2116
Command="{x:Static hyperl:PathTrimmingFileHyperlink.CopyUri}"
@@ -30,10 +25,8 @@
3025
CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"/>
3126
</ContextMenu>
3227
</UserControl.ContextMenu-->
33-
<!--
34-
!!! NOT Using a Grid here because the PathTrimmingTextBlock looks for a parent Grid
35-
!!! to compute its correct size. So, the complete control should be placed inside a Grid.
36-
-->
28+
29+
<Grid>
3730
<TextBlock>
3831
<TextBlock.InputBindings>
3932
<KeyBinding Key="C" Modifiers="Ctrl"
@@ -59,11 +52,12 @@
5952
TextDecorations="{Binding Path=TextDecorations, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperl:PathTrimmingFileHyperlink, AncestorLevel=1},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
6053
>
6154
<ctrl:PathTrimmingTextBlock
62-
ShowElipses="{Binding ShowEllipses, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperl:PathTrimmingFileHyperlink, AncestorLevel=1},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
6355
Path="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperl:PathTrimmingFileHyperlink, AncestorLevel=1},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
6456
Foreground="{DynamicResource {x:Static reskeys:ResourceKeys.Hyperlink_Foreground}}"
65-
/>
66-
<!-- TextBlock Text="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperl:PathTrimmingFileHyperlink, AncestorLevel=1}}" / -->
57+
ShowElipses="{Binding ShowEllipses, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperl:PathTrimmingFileHyperlink, AncestorLevel=1},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
58+
>
59+
</ctrl:PathTrimmingTextBlock>
6760
</Hyperlink>
6861
</TextBlock>
62+
</Grid>
6963
</UserControl>

0 commit comments

Comments
 (0)