1

I'm working on a Silverlight Polling control. My goal is to have a Button that contains other controls, so that when a user clicks on this combination, stuff happens.

Here's the basic XAML:

<Button Grid.Row="1" Grid.Column="0" Style="{StaticResource AnswerButton}">
   <StackPanel Grid.Row="1" Grid.Column="0" Height="Auto" Width="Auto" Style="{StaticResource StackPnl}">
      <TextBox Text="this is a text box" Style="{StaticResource Answer}" />
      <ProgressBar Style="{StaticResource PollProgress}" />
   </StackPanel>
</Button>

That works fine, but assume I don't have the StackPanel, etc, defined:

<Button Grid.Row="1" Grid.Column="0" Style="{StaticResource AnswerButton}">

</Button>

But that I want to add the StackPanel, TextBox, and ProgressBar at runtime.

Looking at just the first hurdle that I've run into, how do I dynamically add the StackPanel to the Button control?

Alternatively, if someone knows of a better way to do this...

1 Answer 1

3

var panel = new StackPanel();

Button.Content = panel;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.