跑程序的时候遇到了一个很奇怪的BUG,问题详情是这样的:
- System.NotSupportedException HResult=0x80131515
- Message=只有Decorator 或 ScrollViewer 元素可以用作 PART_ContentHost。
- Source=PresentationFramework
后来经过一番排查发现,问题出在一个带下划线的TextBox的控件模板中,源代码是这样的:
<Style TargetType="TextBox">
<Setter Property="SnapsToDevicePixels"
Value="True" />
<Setter Property="UseLayoutRounding"
Value="True" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="FontSize"
Value="24" />
<Setter Property="Width"
Value="300" />
<Setter Property="HorizontalAlignment"
Value="Right" />
&