【发布时间】:2020-08-31 04:30:23
【问题描述】:
我已经看到了一些 SO 问题,但我似乎无法弄清楚如何使用我当前的设置来做到这一点。
我的 Datagrid 包含以下内容:
CellStyle="{StaticResource DataGridContentCellCentering}"
<Style x:Key="DataGridContentCellCentering" TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="{StaticResource PColour}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" />
<ContentPresenter HorizontalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="{StaticResource PColour}"/>
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
<Setter Property="MinHeight" Value="15"/>
</Style>
我的数据网格中有一个 DataGridTextColumn
<DataGridTextColumn Header="{x:Static p:Resources.Sabel}" MinWidth="120"
x:Name="SName" Binding="{Binding SName}" Width="*"
EditingElementStyle="{StaticResource dataGridTextColumnLimit}"/>
我的dataGridTextColumnLimit 在哪里:
<Style x:Key="dataGridTextColumnLimit" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="{StaticResource Balour}"/>
<Setter Property="MaxLength" Value="20"/>
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="TextAlignment" Value="Center"/>
</Style>
当我将鼠标悬停在单元格上时,我想以某种方式显示文本框的文本内容的工具提示。这可能/容易做到吗?
谢谢
【问题讨论】: