小编Mar*_*tin的帖子

RoutedEvent隧道未到达儿童

我找到了很多解释冒泡的例子,但没有关于隧道这是关于隧道,例如父母对孩子.我认为我的主要问题是我不明白如何在子节点中注册路由事件(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)

c# wpf routed-events

5
推荐指数
1
解决办法
1253
查看次数

CComboBox :: GetLBText返回垃圾

我正在填充一个组合框:

    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中.我不明白这是怎么发生的,因为我实际上并没有使用指针.

c++ mfc

3
推荐指数
1
解决办法
1542
查看次数

在GWT中嵌入google-plus

我正在尝试将Google-Plus嵌入到我的GWT应用程序中.我希望它嵌入到Horizo​​ntalPanel中.我确实读过+ 1button开发者谷歌.我没有在stackoverflow中找到任何有关此特定问题的帖子.我的问题可能是我不明白如何将js包含到GUI组件中.如果您将Google+代码添加到Panel中,我将不胜感激.

gwt google-plus

2
推荐指数
1
解决办法
1222
查看次数

标签 统计

c# ×1

c++ ×1

google-plus ×1

gwt ×1

mfc ×1

routed-events ×1

wpf ×1