Advertisement
Guest User

Untitled

a guest
May 27th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.64 KB | None | 0 0
  1. <!-- BinaryTreeNodeView.xaml -->
  2. <UserControl x:Class="BinaryTreeControl.Views.BinaryTreeNodeView"
  3.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7.              xmlns:local="clr-namespace:BinaryTreeControl.Views"
  8.              mc:Ignorable="d">
  9.     <StackPanel>
  10.  
  11.         <TextBlock Text="Node" TextAlignment="Center"/>
  12.  
  13.         <Grid>
  14.             <Grid.ColumnDefinitions>
  15.                 <ColumnDefinition/>
  16.                 <ColumnDefinition/>
  17.             </Grid.ColumnDefinitions>
  18.            
  19.             <ContentControl Grid.Column="0" Content="{Binding Left, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:BinaryTreeNodeView}}"/>
  20.  
  21.             <ContentControl Grid.Column="1" Content="{Binding Right, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:BinaryTreeNodeView}}"/>
  22.         </Grid>
  23.     </StackPanel>
  24. </UserControl>
  25.  
  26.  
  27.  
  28. // BinaryTreeNodeView.cs
  29. using System.Windows.Controls;
  30.  
  31. namespace BinaryTreeControl.Views
  32. {
  33.     /// <summary>
  34.     /// Логика взаимодействия для BinaryTreeNodeView.xaml
  35.     /// </summary>
  36.     public partial class BinaryTreeNodeView : UserControl
  37.     {
  38.         public BinaryTreeNodeView()
  39.         {
  40.             Left = new BinaryTreeNodeView(new BinaryTreeNodeView(null, null), new BinaryTreeNodeView(null, null));
  41.             Right = new BinaryTreeNodeView(new BinaryTreeNodeView(null, null), new BinaryTreeNodeView(null, null));
  42.  
  43.             InitializeComponent();
  44.         }
  45.  
  46.         public BinaryTreeNodeView(BinaryTreeNodeView left, BinaryTreeNodeView right)
  47.         {
  48.             Left = left;
  49.             Right = right;
  50.  
  51.             InitializeComponent();
  52.         }
  53.  
  54.         public BinaryTreeNodeView Left { get; set; }
  55.  
  56.         public BinaryTreeNodeView Right { get; set; }
  57.     }
  58. }
  59.  
  60.  
  61.  
  62. <!-- MainWindow.xaml -->
  63. <Window x:Class="BinaryTreeControl.Views.MainWindow"
  64.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  65.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  66.         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  67.         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  68.         xmlns:local="clr-namespace:BinaryTreeControl.Views"
  69.         mc:Ignorable="d"
  70.         Width="300"
  71.         Height="300"
  72.         Title="MainWindow">
  73.     <Grid>
  74.         <local:BinaryTreeNodeView/>
  75.     </Grid>
  76. </Window>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement