Answer the question
In order to leave comments, you need to log in
Adding elements dynamically in WPF?
Good afternoon! Tell me, is it possible in WPF to describe a complex element in a XAML construct, and then dynamically add it to the layout on a button click? The structure is like this:
<Border Width="Auto" Height="Auto" Visibility="{Binding ElementName=CRGD,Path=IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
<StackPanel>
<Button Margin="5 5 5 5" Background="{StaticResource ButtonGrad}">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" Margin="5 5 5 5">Прибор</TextBlock>
<Image DockPanel.Dock="Top" Margin="5 5 5 5" Source="Pics\NoIm_150x150.bmp" Width="150" Height="Auto" ></Image>
</StackPanel>
</Button>
<Menu Height="Auto" Width="Auto" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="5 5 5 5">
<MenuItem x:Name="MGD" Width="170" Height="35" HorizontalAlignment="Center">
<MenuItem.Icon>
<Image Source="Pics\Down.ico" Margin="2 2 2 2"/>
</MenuItem.Icon>
</MenuItem>
</Menu>
</StackPanel>
</Border>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question