更新时间:2023-10-19 16:54:10
@Isak,谢谢,你的 Background="Transparent"
帮助了我的最终解决方案.
@Isak, thanks, your Background="Transparent"
assisted in my final solution.
我最终放弃了带有定义行/列的网格,并使用了带有嵌套 StackPanel 的网格.
I ultimately threw away the Grid with defined rows / columns, and resorted to a Grid with nested StackPanels.
以前 Grid.Rows 是由 ContentControls 填充的,我用包含我需要显示的信息的本地 Stackpanels 替换了它,这似乎已经解决了它,但只有在我将透明"标签添加到堆栈面板之后一个
Previously the Grid.Rows were being populated by ContentControls, I replaced this with local Stackpanels containing the information I needed to display and that seemed to have solved it, but only after I added the "Transparent" tag to the stackpanels and also a
IsHitTestVisible="False"
在父网格中用作背景图像的图像上.
on an image in the parent grid which serves as a background image.
这是我当前解决方案的示例,第二部分替换了我在原始帖子中看到的代码.
Herewith an example of my current solution, the second part which replaces the code seen in my original post.
首先,在获取相关代码之前的基本源文件布局如下所示:
First, the basic source file layout before getting to the code in question looks like this:
<ResourceDictionary xmlns="...
<DataTemplate DataType="...
<Grid Style="...
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Name="LeftColumn" Grid.Column="0">
<TextBlock Style="{StaticResource TextHeader}"
Text="Review 10 Patients"/>
<Image RenderOptions.BitmapScalingMode="NearestNeighbor"
SnapsToDevicePixels="True"
Stretch="None"
DockPanel.Dock="Top"
IsHitTestVisible="False"
Source="((INSERT IMAGE HERE))" Margin="0,-2,0,10"/>
然后我的解决方案网格如下[替换初始帖子代码]:
And then my solution grid as follows [replaces initial post code]:
<StackPanel>
<StackPanel Background="Transparent" Orientation="Horizontal">
<Image Style="{StaticResource InfoImage}" Margin="3">
<ToolTipService.ToolTip>
<ToolTip Width="200" Style="{StaticResource ToolTip}"
Content="ToolTip 1"/>
</ToolTipService.ToolTip>
</Image>
<TextBlock Width="140" Style="{StaticResource Text_SelfTitle}"
Text="Text Field 1"/>
<TextBlock Width="145" Style="{StaticResource Text_SelfQuestions}"
Text="Text Field 2"/>
</StackPanel>
<StackPanel Background="Transparent" Orientation="Horizontal">
((... similar as above...))
</StackPanel>
<StackPanel Background="Transparent" Orientation="Horizontal">
((... similar as above...))
</StackPanel>
</StackPanel>
</Grid>
</Grid>
如果您遇到类似的情况,希望这对其他人有所帮助.
Hope this helps somebody else should you experience something similar.