显而易见的MaxWidth被忽略,“DisplayBox”TextBlock中的文本显示整个文本,即使此文本继续经过父容器控件(到silverlight区域的边缘)。
<win:HierarchicalDataTemplate x:Key="hierarchicalTemplate" ItemsSource="{Binding _children}">
<Border BorderThickness="0" BorderBrush="Orange" HorizontalAlignment="Stretch" Background="{Binding Converter={StaticResource BackgroundConverter}}">
<toolkit:DockPanel LastChildFill="True" Width="{Binding HeirarchyLevel, Converter={StaticResource WidthConverter}}" Height="20">
<Canvas toolkit:DockPanel.Dock="Right" Width="20" MouseLeftButtonUp="Arrow_MouseLeftButtonDown">
<Rectangle Width="20" Height="20" Fill="Transparent" />
<Line Stroke="Black" X1="5" Y1="10" X2="17" Y2="10" />
<Line Stroke="Black" X1="11" Y1="5" X2="17" Y2="10" />
<Line Stroke="Black" X1="11" Y1="15" X2="17" Y2="10" />
</Canvas>
<Ellipse Canvas.Top="5" Width="10" Height="10" Fill="Green" toolkit:DockPanel.Dock="Right" MouseLeftButtonDown="Ellipse_MouseLeftButtonDown" />
<Canvas Width="Auto" Loaded="TextArea_Loaded">
<TextBlock Name="DisplayBox" FontFamily="Arial" FontSize="17" Foreground="Black" Width="Auto" Text="{Binding TaskName}" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" />
<TextBox Name="EditBox" FontFamily="Arial" FontSize="10" Foreground="Black" Height="20" Text="{Binding TaskName}" Visibility="Collapsed" LostFocus="TextBox_LostFocus" />
<Line Stroke="Black" X1="0" Y1="10" X2="202" Y2="10" Width="Auto" />
</Canvas>
</toolkit:DockPanel>
</Border>
</win:HierarchicalDataTemplate>
答案 0 :(得分:1)
您可以切换到使用网格而不是画布吗?当TextBlock是Grid的子项时,它将被适当地剪切。 Canvas不是这样。
答案 1 :(得分:1)