문제

I am working on WPF application. when I am testing this I provide textblock text "test" in coding and goes to output it displays only "tes", instead this text/word ("test"), all text working fine, like if I provide "test1", it displays "test1". can anyone tell me, why this is so ?

도움이 되었습니까?

해결책

There are so many question here where users say 'hey, this doesn't work', when really, all they need to do is look at their code. You gave us some code (which you really should have added to your question for clarity):

<TextBlock Text="test" HorizontalAlignment="Left" VerticalAlignment="Center" 
    Name="lblUserName" FontSize="16" />

If, instead of coming to this site, creating a new user and asking a question, you had simply put your own code into a new project or Window, then you would see that it works just fine... try it now. :)

As such, like @devhedgehog said, you must have something else in your code that is cutting off the end of your TextBlock. A good way to find the offending element is set the Background properties of your various controls:

<TextBlock Text="test" HorizontalAlignment="Left" VerticalAlignment="Center" 
    Name="lblUserName" FontSize="16" Background="Red" />

Using this, it should be clear that the TextBlock has been cut off. If you set this property on the other controls on your page then you should eventually find the one that is covering or restricting the size of your TextBlock.

It could also be getting cut off by a containing Grid Column or StackPanel if you have not set the Width correctly.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top