私はエラーメッセージを表示するアドレナを持っています。問題は、ウィンドウが小さくても、ウィンドウの下でメッセージが切り詰められることです。 私は、ウィンドウのサイズに応じて、またはユーザーがウィンドウのサイズを変更した場合、ボタンまたは左にadornerを再配置しようとしています。ウィンドウのサイズを変更するときにアドフォナーの位置を変更するにはどうすればよいですか?
テキストボックス:
<TextBox IsReadOnly="False" Grid.Column="3" Grid.Row="0" Text="{Binding TextValue}" />
スタイル:
<ControlTemplate x:Key="errorToolTipTemplate">
<ControlTemplate.Resources>
<Style x:Key="textblockErrorTooltip" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Margin" Value="10 0 10 0" />
</Style>
</ControlTemplate.Resources>
<DockPanel LastChildFill="true">
<Border Height="Auto" Margin="4,0,0,0" Background="Tomato" BorderBrush="Black" BorderThickness="1" CornerRadius="2" DockPanel.Dock="Right">
<TextBlock Style="{StaticResource textblockErrorTooltip}" Text="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
</Border>
<AdornedElementPlaceholder Name="customAdorner">
<Border BorderBrush="Red" BorderThickness="1" />
</AdornedElementPlaceholder>
</DockPanel>
</ControlTemplate>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Width" Value="120" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Margin" Value="0,2,4,2" />
<Setter Property="Validation.ErrorTemplate" Value="{DynamicResource errorToolTipTemplate}" />
<!--<Setter Property="FontSize" Value="8" />-->
<Setter Property="Background" Value="{DynamicResource entryFieldsBrush}" />
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Background" Value="{StaticResource windowBrush}" />
</Trigger>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding Path=(Validation.Errors)[0].ErrorContent, RelativeSource={x:Static RelativeSource.Self}}" />
</Trigger>
</Style.Triggers>
</Style>
コントロールのマージンを指定しようとしましたか? – mm8
@ mm8私は、テキストボックスとスタイルに使用している正確なコードを含む質問を更新しました。私は余白とテンプレートの位置を更新しようとしました – IBRA
それは私の質問に答えることはありません。 TextBlockに十分な大きさの右マージンを設定した場合、クリップされてはなりません。 – mm8