将依赖属性设置为 XAML 元素时遇到问题。XAML:
<local2:RichTextColumns xmlns:local2="using:App2.Common">
<local2:RichTextColumns.ColumnTemplate>
<DataTemplate x:Name="overflowControl1">
<RichTextBlockOverflow Width="1000" Margin="5,0,0,0"/>
</DataTemplate>
</local2:RichTextColumns.ColumnTemplate>
<RichTextBlock Foreground="Black" Width="1000">
<Paragraph>
</Paragraph>
</RichTextBlock>
</local2:RichTextColumns>
C#
var tmp = (DataTemplate)FindName("overflowControl1");
tmp.SetValue(RichTextBlockOverflow.ActualWidthProperty, 100);
结果是
灾难性故障(HRESULT 异常:0x8000FFFF (E_UNEXPECTED))。
我也尝试过使用RichTextBlockOverflow.WidthProperty
先感谢您 :)