CodeJock Markup XAML入门

分享到:
  来源:急速科技  发布时间:2014-05-29  浏览次数:2263

  CodeJock Markup XAML

在CodeJock中支持XAML标签的控件有:

  • Calendar
  • CheckBox
  • Label
  • List Box
  • Push Button
  • Radio Button
  • Tab Control
  • Task Dialog
  • TaskPanel
  • Tree View 

类名:CLoginDlg

//在Static控件中增加XAML字符串

CXTPMarkupStatic m_markupStaticParam;

//要首先注册事件才能正确解析

//鼠标进入去事件

m_markupStaticParam.GetMarkupContext()->SetDelegate(L"OnLoginHover", CreateMarkupClassDelegate(this, &CLoginDlg::OnLoginHover));

//鼠标离开事件

m_markupStaticParam.GetMarkupContext()->SetDelegate(L"OnLoginLeave", CreateMarkupClassDelegate(this, &CLoginDlg::OnLoginLeave));

m_markupStaticParam.SetMarkupText(
_T("<StackPanel Margin = '0' Background='#ffffff'>")
//_T("<Border HorizontalAlignment='Left' MouseEnter='OnLoginHover' MouseLeave='OnLoginLeave'><Image Source='file://images/remark.png'/></Border>")//加载文件夹中的图片
//_T("<Border HorizontalAlignment='Left'  ><Image Source='res://#163'/></Border>")//加载资源中的图片163为图片的ID   具体详见CXTPMarkupImage.cpp源文件
_T("<Border Height='20'><TextBlock HorizontalAlignment='Left'>标的:"+ targetID +"</TextBlock></Border>")
_T("<Border Height='20'><TextBlock HorizontalAlignment='Left' >最新价:"+lastprice +"</TextBlock></Border>")
 
_T("<Border Height='20'><TextBlock HorizontalAlignment='Left' >Delta:"+ delta + "</TextBlock></Border>")
 
_T("<Border Height='20'><TextBlock HorizontalAlignment='Left' >Gamma:"+ gamma + "</TextBlock></Border>")
_T("<Border Height='20'><TextBlock HorizontalAlignment='Left' >Vega:"+ vega + "</TextBlock></Border>")
_T("<Border Height='20'><TextBlock HorizontalAlignment='Left' >Theta:"+ theta + "</TextBlock></Border>")
_T("</StackPanel>")
);
 
void CLoginDlg::OnLoginHover(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs)
{
    CXTPMarkupImage* image= NULL;
    if(pSender->IsKindOf(MARKUP_TYPE(CXTPMarkupBorder)))
    {
        image = (CXTPMarkupImage*)pSender->GetLogicalChild(0);
    }else
    {
        image= (CXTPMarkupImage*)pSender;
    }
    image->SetSource("file://images/login_hover.png");
    //CXTPMarkupMouseEventArgs
}
void CLoginDlg::OnLoginLeave(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs)
{
    CXTPMarkupImage* image= NULL;
    if(pSender->IsKindOf(MARKUP_TYPE(CXTPMarkupBorder)))
    {
        image = (CXTPMarkupImage*)pSender->GetLogicalChild(0);
    }else
    {
        image= (CXTPMarkupImage*)pSender;
    }
    image->SetMargin(-1,-1,0,0);
    image->SetSource("file://images/login.png");
 
}

 

 

知识文章分类

C/C++

阅读排行