gpt4 book ai didi

c# - 如何阻止 WPF TextBox 增长

转载 作者:行者123 更新时间:2023-11-30 12:58:18 28 4
gpt4 key购买 nike

当输入长文本时,WPF TextBox 控件会增长。

这个问题已经在 Stackoverflow 中提出了
我也引用了一些答案,但我仍然没有找到有效的正确答案。

Here提到了同样的问题,但没有针对此类问题的有效解决方案。

我已经花了足够的时间来解决这个问题,请帮我解决这个问题。

  <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DockPanel LastChildFill="False" Grid.IsSharedSizeScope="True">
<GroupBox DockPanel.Dock="Top" DataContext="{Binding Data, ValidatesOnNotifyDataErrors=False}">
<GroupBox.HeaderTemplate>
<DataTemplate>
<TextBlock shell:Localization.VbeiTag="vbeiGeneralInformation" Text="General Information"/>
</DataTemplate>
</GroupBox.HeaderTemplate>

<Grid DockPanel.Dock="Top" Margin="0,0,0,3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="GroupA" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="GroupB" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<!--Code Prefix Label -->
<Label Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Content="Code" ></Label>
<Label Grid.Row="0" Grid.Column="2" HorizontalAlignment="Left" Content="Name" ></Label>

<Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Content="Title" ></Label>
<Label Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Content="Long Reference" ></Label>

<Label Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Content="Client Reference"></Label>
<Label Grid.Row="3" Grid.Column="2" HorizontalAlignment="Left" Content="Lead Sub-Business Unit" ></Label>

<!--Code Prefix Editor-->
<common:StudyCodeEditor Grid.Row="0" Grid.Column="1" DataContext="{Binding ValidatesOnNotifyDataErrors=False}"
SuggestedStudyCodePrefixRange="{ViewModelBinding SuggestedStudyCodePrefixRange}"/>

<!--Study Name-->
<TextBox Grid.Row="0" Grid.Column="3" Margin="3" VerticalAlignment="Top"
Text="{Binding StudyName, UpdateSourceTrigger=PropertyChanged}" />

<!--Study Title -->
<TextBox Grid.Row="1" Grid.Column="1" Margin="3" Grid.ColumnSpan="3" VerticalAlignment="Top"
Text="{Binding StudyOfficialTitle, UpdateSourceTrigger=PropertyChanged}" />

<!--Client Long Reference -->
<TextBox Grid.Row="2" Grid.Column="1" Margin="3" Grid.ColumnSpan="3" VerticalAlignment="Top"
Text="{Binding StudyClientLongReference, UpdateSourceTrigger=PropertyChanged}" />

<!--Client Study Reference-->
<TextBox Grid.Row="3" Grid.Column="1" Margin="3" VerticalAlignment="Top"
Text="{Binding ClientStudyReference, UpdateSourceTrigger=PropertyChanged}" />

<!-- Description -->
<TextBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="3"
Text="{Binding Description}" AcceptsReturn="True" DockPanel.Dock="Top"
TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="3" Height="62"/>
</Grid>
</GroupBox>
</DockPanel>
</ScrollViewer>

最佳答案

MaxWidth 应该可以解决问题。如果不是,您的情况出了什么问题?

关于c# - 如何阻止 WPF TextBox 增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30398574/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com