0

在我的 wpf 应用程序中,文本块文本属性绑定到对象的字符串属性。字符串属性值为“ABC-XYZ2014-HHH”。

但是文本块或文本框都不能正确显示该值。值在文本块和文本框中显示为“ABC-XYZ2014-”

我发现标签将“_”或“-”解释为加速键,但我使用的是文本块和文本框。但是第二个“-”之后的值没有显示在文本块和文本框中。我可以在 MessageBox 中看到正确的值。

<UserControl x:Class="KaliteKontrol.PresentationLayer.Denetim"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:igEditors="http://infragistics.com/Editors"
         xmlns:ig="http://schemas.infragistics.com/xaml"
         xmlns:GridControlLib="clr-namespace:CommonLib.Utils;assembly=CommonLib"
         xmlns:commonLibUtils="clr-namespace:CommonLib.Utils;assembly=CommonLib"
         xmlns:igDP="http://infragistics.com/DataPresenter"
         xmlns:sys="clr-namespace:System;assembly=mscorlib"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
    <BooleanToVisibilityConverter x:Key="BoolVisibilityConverter" />
    <Style TargetType="ContentPresenter">
        <Setter Property="RecognizesAccessKey" Value="False" />
    </Style>
</UserControl.Resources>
<ScrollViewer VerticalScrollBarVisibility="Visible">
    <StackPanel  x:Name="mainPanel" Style="{StaticResource ResourceKey=MainWindowsStyle}" >
        <Button>
            <TextBlock Text="{Binding Path=Denetim.DRef}" />
        </Button>
        <Button IsCancel="True"  >

                    <AccessText Margin="10,0,10,0" Text="{Binding Path=Denetim.DRef}"/>
        </Button>
        <TextBox Text="{Binding Path=Denetim.DRef}" Width="500"    />
        <TextBlock Text="{Binding Path=Denetim.DRef}" Width="800"    />
        <Label Content="{Binding Path=Denetim.DRef}"   />
  </StackPanel>
</ScrollViewer>
</UserControl>

谢谢奥努尔

4

1 回答 1

2

显然,文本的结尾TextBlock被某些东西截断或隐藏了。您可以通过将TextBlock具有相同文本的新窗口添加到不同的窗口来验证这一点……您会立即看到它可以正常工作。所以这里唯一的问题是'隐藏文本结尾的是什么

要找出这一点,只需将Background周围元素的属性设置为各种颜色,直到在TextBlock. 然后,您将知道哪个元素隐藏了文本的结尾。

You set the Width of the TextBlock and TextBox, but you didn't set it on the StackPanel or ScrollViewer. My guess is that your StackPanel is causing the problem because they are not controls that you can use to fit-to-size.

于 2014-01-16T14:22:31.383 回答