私のXAMLには次のものがあります:
<DataTemplate x:Key="ValueParserTemplate">
<v:EditableTextBlock x:Name ="scalarEditorTextBox" Margin="17,3,0,0" Width="134" Height="29"
FontFamily="Microsoft Sans Serif" FontSize="13"
Visibility="{Binding IsValueEditorVisible,Converter={StaticResource BoolToVisibility}}"
Text="{Binding Path=DisplayValue, UpdateSourceTrigger=Explicit, Mode=TwoWay,
ValidatesOnDataErrors=True,
ValidatesOnExceptions=True}"
Focusable="True"
TextAlignment="{Binding PxValueDefinition,Converter={StaticResource aignmentConverter}}"
ReadOnly="{Binding IsOutput, RelativeSource={RelativeSource AncestorType={x:Type vo:OutputTreeView}}}"
ScalarDataType="{Binding Path=PxValueDefinition}"
TextBlockBackgroundColor="{StaticResource ScalarBackground}"
TextBoxBackgroundColor="{StaticResource ScalarBackground}"
Background="{StaticResource ScalarBackground}"
BorderBrush ="Black" BorderThickness="1,1,1,1"/>
</DataTemplate>
そして、TextBlock のテキストに内部パディングが必要です。追加してみました:
padding="5,5,5,5" -> no success
padding="50" -> no success
何も機能しません。見る:
どうすれば欲しいものを手に入れることができるか分かりますか?
ありがとうございました。
編集: ああ... EditableTextBlock にパディングを追加する必要があると思います! EditableTextBlock XAML:
<Style TargetType="{x:Type v:EditableTextBlock}">
<Setter Property="MinWidth" Value="134"/>
<Setter Property="MinHeight" Value="16"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type v:EditableTextBlock}">
<Border Name="Border" BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}}" BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}}" SnapsToDevicePixels="True">
<Grid x:Name="PART_GridContainer" Background="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<TextBlock x:Name="PART_TbDisplayText" Visibility="Visible"
Background="{Binding TextBlockBackgroundColor, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}}"
Foreground="{Binding TextBlockForegroundColor, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}}"
Text="{Binding Text, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}, Mode=TwoWay}"
VerticalAlignment="Center" Padding="0,0,3,0"/>
<TextBox x:Name="PART_TbEditText"
Visibility="Hidden"
Background="{Binding TextBoxBackgroundColor, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}}"
Foreground="{Binding TextBoxForegroundColor, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}}"
Text="{Binding Text, RelativeSource={RelativeSource AncestorType={x:Type v:EditableTextBlock}}, Mode=TwoWay}"
BorderThickness="0" VerticalAlignment="Center"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="LightGray"/>
<Setter TargetName="Border" Property="BorderBrush" Value="Black"/>
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
<Trigger Property="Validation.HasError" Value="true">
<Setter TargetName="Border" Property="BorderBrush"
Value="Red"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="ShowFocusVisual" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>