Silverlight - Basic Container for a bunch of elements
I have 3 things that I'd like to wrap up in something so that I can call the container from code and not each thing individually.
I can see there is a Canvas
container but isn't there something more generic that just serves as a package that I can call?
Her开发者_如何转开发e is my current code:
<Rectangle Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="3" Fill="Black" Width="420" Height="480" Opacity=".5"></Rectangle>
<Rectangle Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="3" Fill="Black" Width="100" Height="50" VerticalAlignment="Top" Margin="0,50,0,0" RadiusX="5" RadiusY="5"></Rectangle>
<TextBlock Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="3" Foreground="White" Text="Loading" HorizontalAlignment="Center" Margin="0,65,0,0"></TextBlock>
I wish I could do this:
<Container>
<Rectangle Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="3" Fill="Black" Width="420" Height="480" Opacity=".5"></Rectangle>
<Rectangle Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="3" Fill="Black" Width="100" Height="50" VerticalAlignment="Top" Margin="0,50,0,0" RadiusX="5" RadiusY="5"></Rectangle>
<TextBlock Grid.Column="0" Grid.Row="3" Grid.RowSpan="2" Grid.ColumnSpan="3" Foreground="White" Text="Loading" HorizontalAlignment="Center" Margin="0,65,0,0"></TextBlock>
</Container>
BTW, this should look something like this:
---------------
| --------- |
| | Loading | |
| --------- |
| |
| |
| |
| |
---------------
Thank you,
Aaron
The question is not making much sense but are you looking for a UserControl?
(The link refers to Silverlight 2.0 but it is still valid)
If you want to style the controls with a single template you'll need a Custom Control (inherit from Control)
精彩评论