Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- BinaryTreeNodeView.xaml -->
- <UserControl x:Class="BinaryTreeControl.Views.BinaryTreeNodeView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:BinaryTreeControl.Views"
- mc:Ignorable="d">
- <StackPanel>
- <TextBlock Text="Node" TextAlignment="Center"/>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <ContentControl Grid.Column="0" Content="{Binding Left, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:BinaryTreeNodeView}}"/>
- <ContentControl Grid.Column="1" Content="{Binding Right, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:BinaryTreeNodeView}}"/>
- </Grid>
- </StackPanel>
- </UserControl>
- // BinaryTreeNodeView.cs
- using System.Windows.Controls;
- namespace BinaryTreeControl.Views
- {
- /// <summary>
- /// Логика взаимодействия для BinaryTreeNodeView.xaml
- /// </summary>
- public partial class BinaryTreeNodeView : UserControl
- {
- public BinaryTreeNodeView()
- {
- Left = new BinaryTreeNodeView(new BinaryTreeNodeView(null, null), new BinaryTreeNodeView(null, null));
- Right = new BinaryTreeNodeView(new BinaryTreeNodeView(null, null), new BinaryTreeNodeView(null, null));
- InitializeComponent();
- }
- public BinaryTreeNodeView(BinaryTreeNodeView left, BinaryTreeNodeView right)
- {
- Left = left;
- Right = right;
- InitializeComponent();
- }
- public BinaryTreeNodeView Left { get; set; }
- public BinaryTreeNodeView Right { get; set; }
- }
- }
- <!-- MainWindow.xaml -->
- <Window x:Class="BinaryTreeControl.Views.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:BinaryTreeControl.Views"
- mc:Ignorable="d"
- Width="300"
- Height="300"
- Title="MainWindow">
- <Grid>
- <local:BinaryTreeNodeView/>
- </Grid>
- </Window>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement