{
System::Collections::Generic::List
pDependencyObject = gcnew System::Collections::Generic::List
if (source != nullptr)
{
GetChildObjects(source, pDependencyObject);
for each ( System::Windows::DependencyObject^ child in pDependencyObject)
{
if ( dynamic_cast
{
//MessageBox::Show ( "Yes Add" + child->GetType()->ToString());
pList->Add( (System::Windows::Controls::Control^)child );
}
//else
//MessageBox::Show ( "Not need" + child->GetType()->ToString());
}
}
}
void GetChildObjects(System::Windows::DependencyObject^ parent, System::Collections::Generic::List
{
bool bContentElement = false;
bool bFrameworkElement = false;
if (parent == nullptr)
return;
if ( dynamic_cast
bContentElement = true;
else
bContentElement = false;
if ( dynamic_cast
bFrameworkElement = true;
else
bFrameworkElement = false;
if ( ( bContentElement == true ) || ( bFrameworkElement == true ) )
{
for each (System::Object^ obj in System::Windows::LogicalTreeHelper::GetChildren(parent))
{
System::Windows::DependencyObject^ depObj = nullptr;
if ( dynamic_cast
depObj = (System::Windows::DependencyObject^)obj;
if (depObj != nullptr)
{
pDependencyObject->Add( (System::Windows::DependencyObject^)obj );
//MessageBox::Show( ((System::Windows::DependencyObject^)obj)->GetType()->ToString() );
GetChildObjects( (System::Windows::DependencyObject^)obj, pDependencyObject );
}
}
}
}
call the function
List
pControlList = gcnew List
FindChildren(pDialog, pControlList); //Load controls from dialog
for each ( System::Windows::Controls::Control^ pControl in pControlList )
{
//your checking
}
No comments:
Post a Comment