我找到了很多解释冒泡的例子,但没有关于隧道这是关于隧道,例如父母对孩子.我认为我的主要问题是我不明白如何在子节点中注册路由事件(WindowControl到UserControl).我有:
public partial class MyParent : UserControl
{
public static readonly RoutedEvent RoutedMouseUpEvent = EventManager.RegisterRoutedEvent(
"PreviewMouseLeftButtonUp", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(WindowControl));
// Provide CLR accessors for the event
public event RoutedEventHandler MouseUp
{
add { AddHandler(RoutedMouseUpEvent, value); }
remove { RemoveHandler(RoutedMouseUpEvent, value); }
}
public addView(UserControl view)
{
WindowControl win = new WindowControl();
win.Content = view;
}
private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(MyParent.RoutedMouseUpEvent);
RaiseEvent(newEventArgs);
}
}
Run Code Online (Sandbox Code Playgroud)
addView的封装是必要的,应该没问题吗?通过addView添加子项.调用Grid_MouseLeftButtonUp.
接收器看起来像这样(它是mvvm所以没有太多):
public partial class ChildView : UserControl
{
void …Run Code Online (Sandbox Code Playgroud) 我正在填充一个组合框:
while((pHPSet = pHPTable->GetNext()) != NULL)
{
CString str = pHPSet->GetName();
// I am normally using str but to proove that this is
// not the problem I am using "a"
m_comboBaseHP.AddString(_T("a"));
}
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试阅读组合框:
if(m_comboBaseHP.GetCount() > 0)
{
CString csHPName = _T("");
m_comboBaseHP.GetLBText(0, csHPName);
// This is the ms way but ReleaseBuffer causes a crash
//CString str = _T("");
//int n = m_comboBaseHP.GetLBTextLen( 0 );
//m_comboBaseHP.GetLBText( 0, str.GetBuffer(n) );
//str.ReleaseBuffer();
// Do whatever with csHPName
}
Run Code Online (Sandbox Code Playgroud)
问题是csHPName在Debugger中显示了一些中文符号.我假设这是内存垃圾.这发生在同一个方法中.这种情况发生在预抽.发布同样的问题.这发生在Debug和Release中.我不明白这是怎么发生的,因为我实际上并没有使用指针.
我正在尝试将Google-Plus嵌入到我的GWT应用程序中.我希望它嵌入到HorizontalPanel中.我确实读过+ 1button开发者谷歌.我没有在stackoverflow中找到任何有关此特定问题的帖子.我的问题可能是我不明白如何将js包含到GUI组件中.如果您将Google+代码添加到Panel中,我将不胜感激.