Windows 8 Metro アプリでは複数の画面解像度をサポートする必要があるため、RichTextBlockOverflow コントロール (または、表示するテキストの量に応じて複数のコントロール) で切り取られるテキストを表示するために、RichTextBlock を分割したいと考えています。追加の RichTextBlockOverflow-Control を表示する必要があるかどうかを判断するために、RichTextBlocks の HasOverflowContent-Property を確認します。しかし、それは常に false を返します。
再現するのはとても簡単です:
- 新しい「Windows ストア -> 空のアプリ」を作成します。
MainPage.xaml の xaml を次のコードに置き換えます。
<StackPanel Orientation="Horizontal" Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <RichTextBlock x:Name="test1" Width="100" Height="300" OverflowContentTarget="{Binding ElementName=test}"> <Paragraph> lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s lkj halks dflkjha skld fkla hsdkl hfakl dsflk hasdkl fakl hsdklf halks dflka jhsdhfklaj hsdklf jhakls dflkaj hsdlkfjh alks dflkajh s </Paragraph> </RichTextBlock> <RichTextBlockOverflow x:Name="test" Width="100" Height="300" /> </StackPanel>
次に、コード ビハインド ファイル (MainPage.xaml.cs) に移動し、コンストラクターをそのコードに置き換えます。
public MainPage()
{
this.InitializeComponent();
if (test.HasOverflowContent)
{
// Will never be entered
}
if (test1.HasOverflowContent)
{
// Will never be entered
}
}
this.InitializeComponent() にブレークポイントを設定し、HasOverflowContent が真にならないことを確認します。
私は何を間違っていますか?それとも.NETのバグですか?
どんな助けでも大歓迎です;)
そして私