Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XAML
- <Window x:Class="ControlTest.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:ControlTest"
- mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800">
- <StackPanel Width="100" x:Name="spMain">
- <Button />
- <Button />
- <Button />
- <Label Content="Yo." />
- <Button />
- <Button />
- <Button />
- </StackPanel>
- </Window>
- Code
- using System;
- using System.Windows;
- using System.Windows.Controls;
- namespace ControlTest
- {
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- Random random = new Random();
- foreach (object x in spMain.Children)
- {
- if (x is Button button)
- {
- button.Content = Math.Floor(random.NextDouble() * 25);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment