2
我想获得对ElementHost控件的引用。例如,在下面的代码中,我需要最初使用WPF用户控件的“testImage”内容来为事件提供午餐。 WPF控件在运行时添加,ElementHost控件也添加了,所以我不能使用WPF控件的名称或ElementHost的名称。 我的逻辑是获取“testImage”的父级WPF用户控件,然后获取WPF用户控件的父级ElementHost。 但我有麻烦写在代码中。请指教。谢谢。如何获取ElementHost控件,给定WPF控件的内容
<UserControl x:Class="WpfTest”
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="300" Height="300">
<Grid>
<Label FontSize="10" Height="24" Margin="74,16,0,0" Name="testLabel" VerticalAlignment="Top" />
<Image Name="testImage" Stretch="Uniform" HorizontalAlignment="Left" Width="64" Height="81" VerticalAlignment="Top" Margin="8,0,0,0"/>
</Grid>
</UserControl>
谢谢,我会试试看。我会让知道它是否有帮助。 – Serg 2010-01-29 21:57:35
它为我工作!谢谢。晚回复,但你真的帮助了一个人:) – Zer0 2014-11-18 22:49:53