来自radtreeview的Telerik控件:如何获取父节点下所有节点的数量并编辑treeview的内容?

时间:2016-04-29 06:02:38

标签: c# wpf telerik radtreeview

我正在尝试创建一个用户控件,它自动在文本框中填充radtree视图的内容。用户控件应该允许我获取父节点下所有节点的计数,并且它应该允许我通过用户控件中的文本框编辑树视图的内容,并且这些更改应该反映在树中。有人可以帮忙吗?

Usercontrol xaml代码

UserControl
             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:TreeviewUControl"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="TreeviewUControl.UserControl1"
             mc:Ignorable="d" 
              d:DesignWidth="300" Height="350">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="200"/>


        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <!-- <Label Content="this is test"  Name="testLbl" /> -->
        <Label x:Name="Name" Grid.Row="0" Content="Name" Margin="10"/>
        <Label x:Name="Services" Grid.Row="1" Content="Services" Margin="10" />
        <Label x:Name="Scripts" Grid.Row="2" Content="Scripts" Margin="10" />
        <Label x:Name="Scenarios" Grid.Row="3" Content="Scenarios" Margin="10" />
        <telerik:RadWatermarkTextBox x:Name="ProjectName" Grid.Column="1" HorizontalAlignment="Left" Margin="10"  Text="RadWatermarkTextBox" Width="150" TextChanged="projectnameChanged"/>
        <telerik:RadWatermarkTextBox x:Name="radWatermarkTextBox1" Grid.Column="1" HorizontalAlignment="Left" Margin="10" Grid.Row="2" Text="RadWatermarkTextBox" Width="150" />
        <telerik:RadWatermarkTextBox x:Name="radWatermarkTextBox2" Grid.Column="1" HorizontalAlignment="Left" Margin="10" Grid.Row="3"  Text="RadWatermarkTextBox" Width="150" />
        <telerik:RadButton x:Name="radButton" Content="Save changes" HorizontalAlignment="Left" Height="37"  Grid.Row="3" VerticalAlignment="Top" Width="88" Click="Savechanges" Margin="10,117,0,-103"/>
        <telerik:RadButton x:Name="radButton1" Content="Export" Grid.Column="1" HorizontalAlignment="Left" Height="37"  Grid.Row="3" VerticalAlignment="Top" Width="88" Margin="38,117,0,-103"/>



    </Grid>
</UserControl>

mainwindowXaml.cs

public partial class MainWindow : Window
{
    private string selectedPath;

    public MainWindow()
    {
        InitializeComponent();

    }
   private void treenodeclick(object sender, System.EventArgs e)
    {
        UserControl1 uc = new UserControl1();
        Stakname.Children.Add(uc);
        selectedPath = RadTreeView.SelectedValuePath;
        uc.ProjectName.Text = RadTreeView.SelectedItem.ToString();

    }

Mainwindow xaml

                                                                                                                                                                                                                                                                               

0 个答案:

没有答案