D
D
Denis Mashanov2017-09-16 07:42:55
WPF
Denis Mashanov, 2017-09-16 07:42:55

How to get element properties?

Good afternoon everyone. Help me please. When accessing ListCheckBox.Children (ListCheckBox is

<StackPanel x:Name="ListCheckBox" Margin="0" Width="284">
), then I only get the properties of the UI, but how do I get the properties of the element?
In this example, when accessing ListCheckBox.Children[0], the IsChecked property is not visible, as it returns a UIElementCollection of the child elements of this Panel:
<StackPanel x:Name="ListCheckBox" Margin="0" Width="284">
                        <CheckBox x:Name="All" Content="Выбрать все" HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="1,1,1,5" IsChecked="True"/>
  </StackPanel>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Mashanov, 2017-09-16
@LoneRay

I figured out how to do it)

foreach (object child in ListCheckBox.Children)
            {
                var element = child as CheckBox;
                if (!element.Name.Equals("All"))
                    element.IsChecked = All.IsChecked;
            }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question