我有以下代码:
public class IdentityCell : Panel
{
public IdentityCell()
{
Margin = m_zeroThickness;
VerticalAlignment = VerticalAlignment.Top;
Width = double.NaN;
m_labelIcon = new Image();
{
m_labelIcon.VerticalAlignment = VerticalAlignment.Center;
m_labelIcon.Width = getIconSizeToUseInPixels();
m_labelIcon.Height = getIconSizeToUseInPixels();
}
Children.Add(m_labelIcon);
m_labelName = new TextBox();
{
m_labelName.Margin = m_zeroThickness;
m_labelName.VerticalAlignment = VerticalAlignment.Center;
m_labelName.TextAlignment = TextAlignment.Center;
m_labelName.FontSize = (double)
Application.Current.Resources["PhoneFontSizeMediumLarge"];
m_labelName.Padding = m_zeroThickness;
m_labelName.IsHitTestVisible = false;
m_labelName.BorderThickness = m_zeroThickness;
m_labelName.Width = double.NaN;
m_labelName.Foreground = m_phoneForegroundBrush;
m_labelName.Background = null;
}
Children.Add(m_labelName);
IsHitTestVisible = true;
Tap += onTap;
}
...
}
点击m_labelIcon时,会调用onTap()。但是当点击m_labelName时,不会调用onTap()。如果我将m_labelName.IsHitTestVisible设置为true,则点击m_labelName会使控件进入编辑模式并弹出屏幕键盘。 m_labelName应该只是一个静态文本控件而没有编辑支持。我尝试过使用IsEnabled或IsReadOnly属性,但这会改变外观。
我的TextBox位于我的图片旁边。布局如下所示:
---- Panel --------------------
<Image> < TextBox >
---- Panel --------------------
任何帮助将不胜感激!
由于