2012-08-16 51 views
0

這裏沒有顯示是我寫的代碼:滾動條和多線文本

   <Grid> 
        <Grid.Resources> 
         <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> 
        </Grid.Resources> 
        <TextBlock Margin="3,0,3,0" VerticalAlignment="Center" 
         Text="Comment here..."             
         FontSize="12" 
         Foreground="Black" 
         Height="35" 
         Visibility="{Binding ElementName=TextBox1, Path=Text.IsEmpty, 
         Converter={StaticResource BooleanToVisibilityConverter}}"/> 
        <TextBox Margin="0" Background="#AAFFFFFF" 
         VerticalAlignment="Top" Name="FilterTextBox" 
         Text="{Binding Text, UpdateSourceTrigger=PropertyChanged}" 
         MinLines="2" 
         MaxLines="2" 
         BorderThickness="0" 
         VerticalScrollBarVisibility="Auto"        
         MaxLength="{Binding MaxLength}" 
         Height="35"> 
        </TextBox> 
       </Grid>   

這工作根據需要,如果我進入這裏刪除評論的信...但問題是,我已經設置爲文本框MinLines = 2和滾動條可見,但兩者都不起作用。我只能在一行中輸入文本。任何人都可以告訴我我做錯了什麼?或者有沒有更好的方式在wpf中做到這一點?

+1

試試這個http://adnan8t2p.blogspot.co.il/2009/03/wpf-multiline-textbox.html – Yoav 2012-08-16 15:18:23

回答