我正在研究一个日历程序,它主要由WPF DataGrid
组成。由于没有足够的空间来显示一天中的所有条目(这是一个DataGridCell
),包含day shell全部条目的工具提示出现在鼠标悬停处。这到目前为止工作与下面的代码片段。现在(小)问题:如果一天没有条目,则不会弹出工具提示框。用下面的代码弹出一个空的工具提示。防止wpf数据网格空工具提示
<DataGridTemplateColumn x:Name="Entry"
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding EntryText}"
Foreground="{Binding EntryForeground}"
FontWeight="{Binding EntryFontWeight}">
</TextBlock>
<TextBlock Text="{Binding RightAlignedText}"
Foreground="Gray"
Background="Transparent">
<TextBlock.ToolTip>
<TextBlock Text="{Binding AllEntriesText}"/>
</TextBlock.ToolTip>
</TextBlock>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
数据绑定经由
myCalDataGrid.Itemssource = _listOfDays;
在代码所做的后面,其中,A“日”为单个日历行视图模型。
感谢您的回答。我会检查一下并发送一份报告。 – TheCalendarProgrammer
好答案,像魅力一样工作。 – Mark