Print Page | Close Window

Markup Dynamic

Printed From: Codejock Forums
Category: General
Forum Name: XAML Snippets
Forum Description: Post your XAML snippets here for everyone to enjoy :)
URL: http://forum.codejock.com/forum_posts.asp?TID=13245
Printed Date: 23 November 2024 at 11:16pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Markup Dynamic
Posted By: Jose5
Subject: Markup Dynamic
Date 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!!!



Replies:
Posted By: Oleg
Date 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


Posted By: Jose5
Date 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!!!


Posted By: Oleg
Date Posted: 26 January 2009 at 3:06pm
Hi,
 
Sorry, I don't get question.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Jose5
Date 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!!!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net