Search code examples
c#.netsilverlightradio-buttonstackpanel

How to set IsEnabled property of stackpanel


I am programtaically doing this part. I want to set the UIElelemnts (radiobuttons) present on this stackpanel to partially visible so i want any equivalent property which can make the stackpanel property IsEnabled set to False (any quivalent property or any other way to achieve this because IsEnabled is not supported by stackpanel).

Or if it is possible to have another conntainer which could be parent of stackpanel and also supports IsEnabled property. (please do not suggest to set IsEnabled false for every radiobutton in loop when i set them on stackpanel because i cannot do this because of current situation in code i want some bigcontainer which can be set to IsEnabled).


Solution

  • Try to Wrap the stack panel with the content template and set it’s IsEnabled property to false.

    <ContentControl IsEnabled="false">
        <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="5">       
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="20"/>
                </Grid.RowDefinitions>
    
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="70"/>
                    <ColumnDefinition Width="90"/>
                </Grid.ColumnDefinitions>
    
                <TextBlock Text="Fullname" Grid.Row="0" Grid.Column="0" />
                <TextBox Grid.Row="0" Grid.Column="1"/>
                <TextBlock Text="Address" Grid.Row="1" Grid.Column="0"/>
                <TextBox Grid.Row="1" Grid.Column="1"/>
            </Grid>
            <Button Content="Update" Margin="5" Width="100"/>
        </StackPanel>
    </ContentControl>