2011-11-08 11 views
2

私はカスタムコントロールを内部に持っています。私はテキストボックスを折りたたんだり展開したりしたいと思っています。縦に伸ばせば水平にしたい。Silverlight、テキストボックスを回転させるとすべてのテキストが表示されない

問題は、テキストボックスにテキストがすべて表示されない場合、回答を探していて、Silverlightのレイアウトの更新方法と関係があることです。ここに私のコードは

private void CollapseControl() 
{ 
    CollapseCommand.Content = "E";    
    CollapseCommand.Margin = _btnMarginOnCollapse; 

    BtnZoomIn.Visibility = Visibility.Collapsed; 
    BtnZoomOut.Visibility = Visibility.Collapsed; 
    ScrollViewerStackPanel.Visibility = Visibility.Collapsed; 
    ZoomPanel.Visibility = Visibility.Collapsed; 

    this.HorizontalAlignment = HorizontalAlignment.Left; 
    this.Width = 40; 

    RotateTransform nameRotateTransform = new RotateTransform(); 
    nameRotateTransform.Angle = 270;    
    Nametb.RenderTransform = nameRotateTransform;    
    Nametb.VerticalAlignment = VerticalAlignment.Bottom; 
    Nametb.Height = Nametb.Width; 
    Nametb.Width = Nametb.Height; 
    Nametb.UpdateLayout(); 

} 

答えて

3

一つの解決策はSilverlight toolkitからLayoutTransformerコントロールを使用することですです。あなたはLayoutTransformer

 <toolkit:LayoutTransformer x:Name="Namelt" ...> 
      <toolkit:LayoutTransformer.LayoutTransform> 
       <RotateTransform /> 
      </toolkit:LayoutTransformer.LayoutTransform> 
      <TextBlock x:Name="Nametb" Text="Hello World" /> 
     </toolkit:LayoutTransformer> 

内の既存のテキストブロックをラップ

は、次に、あなたのコードは次のようになります -

((RotateTransform)Namelt.LayoutTransform).Angle = 270;       
Namelt.VerticalAlignment = VerticalAlignment.Bottom;  
Namelt.Height = Nametb.Width;  
Namelt.Width = Nametb.Height; 
+1

ありがとう、それは私を助けました –

0

私は最近、同様の問題に遭遇した、と(下記の溶液を思い付いa post on the Silverlight forumsに基づいて)、あなたの問題にも役立ちます:

private void CollapseControl() 
{ 
    CollapseCommand.Content = "E"; 
    CollapseCommand.Margin = _btnMarginOnCollapse; 

    BtnZoomIn.Visibility = Visibility.Collapsed; 
    BtnZoomOut.Visibility = Visibility.Collapsed; 
    ScrollViewerStackPanel.Visibility = Visibility.Collapsed; 
    ZoomPanel.Visibility = Visibility.Collapsed; 

    this.HorizontalAlignment = HorizontalAlignment.Left; 

    LayoutTransform lt = new LayoutTransform(); 
    lt.Content = Nametb; 

    RotateTransform nameRotateTransform = new RotateTransform(); 
    nameRotateTransform.Angle = 270; 

    lt.LayoutTransform = nameRotateTransform; 
    lt.ApplyLayoutTransform(); 
    Nametb.UpdateLayout(); 
} 
0

私はちょうど次のように書かれ、私の同様の問題は解決されます。

layoutTransform.VerticalAlignment = VerticalAlignment.Bottom; 
layoutTransform.VerticalAlignment = VerticalAlignment.Center; 
関連する問題