Search code examples
c#wpfwpf-controlsmaterial-design-in-xamlmaterialdesignthemes

Retrieving Child of Material Design UI Kit Card


I know it is possible to retrieve the children of a container such as a WrapPanel:

UIElementCollection collection = myWrapPanel.Children;

Assume that I have a MaterialDesignThemes.Wpf.Card that contains a container like a WrapPanel.

Note that I don't know the Name of that container!

my question is that...

How to retrieve the child of a MaterialDesignThemes.Wpf.Card?


Solution

  • How to retrieve the child of a MaterialDesignThemes.Wpf.Card?

    Cast its Content property to whatever the type of the "child" is, e.g.:

    var panel = card.Content as Panel;
    var children = panel?.Children;