Codejock Forums Homepage
Forum Home Forum Home > General > XAML Snippets
  New Posts New Posts RSS Feed - Markup Dynamic
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Markup Dynamic

 Post Reply Post Reply
Author
Message
Jose5 View Drop Down
Groupie
Groupie
Avatar

Joined: 07 June 2005
Location: United States
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jose5 Quote  Post ReplyReply Direct Link To This Post Topic: Markup Dynamic
    Posted: 23 January 2009 at 1:39pm
Question to CodeJock Techs

what i Call Dynamic is a way to create a template example
<Page xmlns=...
    <Grid...
         <StackPanel ....
              <Dynamic.1></Dynamic.1>
         </StackPanel


from the CXTPMarkupBuilder::Parse
{
           switch(t)...
             case CXTPMarkupParser::tokenTagEnd:
                       ...
                       if(wcsncmp(lpszTagName), L"Dynamic ",7) == 0)
                          Call Owner via a SendMessage with  StackPanel             object  as WPARAM and Builder as LPARAM
                   ...   
}

Owner::OnDynamicAdd(WPARAM wParam, LPARAM lParam)
{
           CXTPMarkupStackPanel* pObject = (CXTPMarkupStackPanel*)wParam;
    CXTPMarkupBuilder * Builder = (CXTPMarkupBuilder *)lParam;

    CXTPMarkupTextBlock* pTextBlock1 = MARKUP_CREATE(CXTPMarkupTextBlock,this);
    pTextBlock1->SetTextWrapping(1);
    pTextBlock1->SetText(L"You can increment or decrement the value of this" 
                         L"textbox by simply clicking the mouse, hold and drag"
                         L"up or down, right or left. Release when happy,with the value.");
    pTextBlock1->SetMargin(5, 0, 5, 0);
    pTextBlock1->SetBackground(new CXTPMarkupSolidColorBrush(RGB(0xFF, 0, 0)));
    pTextBlock1->SetForeground(new CXTPMarkupSolidColorBrush(RGB(0xFF, 0xFF, 0xFF)));

    pObject->GetChildren()->Add(pTextBlock1);
 
}
hope is not to confusing just a better wat to fill in the markup dynamically
thanks guys 

    
IT WASENT ME!!!
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2009 at 2:47pm
Hi,
 
You almost find solution :)
 
Here how it should work.
 
1. We add new class and register its Tag:
 
class CMyDynamicMarkup : public CXTPMarkupGrid
{
 DECLARE_MARKUPCLASS(CMyDynamicMarkup)
 void SetContentObject(CXTPMarkupBuilder* pBuilder, CXTPMarkupObject* pContent);
};
IMPLEMENT_MARKUPCLASS(L"Dynamic", CMyDynamicMarkup, CXTPMarkupGrid);
void CMyDynamicMarkup::RegisterMarkupClass()
{
}
 
2 Add your dynamic code in SetContentObject
 
void CMyDynamicMarkup::SetContentObject(CXTPMarkupBuilder* pBuilder, CXTPMarkupObject* pContent)
{
 if (IsStringObject(pContent))
 {
  // Here we can use content as parameter;
  
  CXTPMarkupTextBlock* pTextBlock1 = MARKUP_CREATE(CXTPMarkupTextBlock,pBuilder->GetMarkupContext());
  pTextBlock1->SetTextWrapping(1);
  pTextBlock1->SetText(L"You can increment or decrement the value of this" 
   L"textbox by simply clicking the mouse, hold and drag"
   L"up or down, right or left. Release when happy,with the value.");
  pTextBlock1->SetMargin(5, 0, 5, 0);
  pTextBlock1->SetBackground(new CXTPMarkupSolidColorBrush(RGB(0xFF, 0, 0)));
  pTextBlock1->SetForeground(new CXTPMarkupSolidColorBrush(RGB(0xFF, 0xFF, 0xFF)));
  
  GetChildren()->Add(pTextBlock1);
 }
}
 
3. And Markup is
 
<Page>
<Dynamic>parameter</Dynamic>
</Page>
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Jose5 View Drop Down
Groupie
Groupie
Avatar

Joined: 07 June 2005
Location: United States
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jose5 Quote  Post ReplyReply Direct Link To This Post Posted: 23 January 2009 at 3:41pm
what if you want to replace with a row of may be elements
like so
void CMyDynamicMarkup::SetContentObject(CXTPMarkupBuilder* pBuilder, CXTPMarkupObject* pContent)
{
    if (IsStringObject(pContent))
    {
        // Here we can use content as parameter;
        for(int x=0;x<10;x++)
        {
                CXTPMarkupTextBlock* pTextBlock1 = MARKUP_CREATE(CXTPMarkupTextBlock,pBuilder->GetMarkupContext());
                pTextBlock1->SetTextWrapping(1);
                pTextBlock1->SetText(L"1You can increment or decrement the value of this"
                    L"textbox by simply clicking the mouse, hold and drag"
                    L"up or down, right or left. Release when happy,with the value.");
                pTextBlock1->SetMargin(5, 0, 5, 0);
                pTextBlock1->SetBackground(new CXTPMarkupSolidColorBrush(RGB(0xFF, 0, 0)));
                pTextBlock1->SetForeground(new CXTPMarkupSolidColorBrush(RGB(0xFF, 0xFF, 0xFF)));

            if(pTextBlock1)
                GetChildren()->Add(pTextBlock1);
        }

    }
}
IT WASENT ME!!!
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 26 January 2009 at 3:06pm
Hi,
 
Sorry, I don't get question.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Jose5 View Drop Down
Groupie
Groupie
Avatar

Joined: 07 June 2005
Location: United States
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jose5 Quote  Post ReplyReply Direct Link To This Post Posted: 26 January 2009 at 3:57pm
well

let say in my template i have
something like <Dynamic id=1></Dynamic> witch is already declare name space

i want to display many item from within the CMyDynamicMarkup::SetContentObject(CXTPMarkupBuilder* pBuilder, CXTPMarkupObject* pContent)
{
        CXTPMarkupObject* parentContent = CXTPMarkupStackPanel (?);
        add 10 row
        return
      
       the question how to get the parent CXTPMarkupStackPanel class

}

IT WASENT ME!!!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.