Samples for manual creation

4 posts, 0 answers
  1. Greg
    Greg avatar
    7 posts
    Member since:
    Sep 2010

    Posted 15 Apr 2011 Link to this post

    Hi,

    I am trying to use the RadDataForm to display non-CLR based information and am having trouble finding examples of either building the form through the code behind or some other way. What we have is an object that has a collection of properties (KeyValuePairs (names, object)) which are created by the end user and displayed in a PropertyGrid through the ICustomTypeDescriptor interface.

    Thanks for the help,
    Greg
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 20 Apr 2011 Link to this post

    Hi Greg,

    We do not have such example. However I will be glad to help you the following way -
    can you please paste me a sample implementation of your object ( the one you need edited in RadDataForm ) . I will try to prepare a small sample app for you .

    All the best,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Greg
    Greg avatar
    7 posts
    Member since:
    Sep 2010

    Posted 20 Apr 2011 Link to this post

    I have added a fairly simple example where I am using a datatemplate and a stackpanel to achieve the effect of a data driven data entry form.  I will probably end up implementing something using the code behind to facilitate picklists and things like that but I did not see how to do this with the RadDataForm.

    Thanks,
    Greg

    <Window x:Class="Sandbox.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <DataTemplate x:Key="DataForm">
                <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                    <TextBlock Text="{Binding Name}" Width="100"/>
                    <TextBox Text="{Binding Value, Mode=TwoWay }" HorizontalAlignment="Stretch" MinWidth="200" ToolTip="{Binding Description}" />
                </StackPanel>
            </DataTemplate>
        </Window.Resources>
        <Grid>
            <ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Auto">
                <GroupBox Header="Configuration">
                    <StackPanel Orientation="Vertical" Name="ConfigurationStackPanel"  DataContext="{Binding}" Margin="5, 0, 0, 15">
                        <ItemsControl ItemsSource="{Binding}" ItemTemplate="{StaticResource DataForm}"/>
                    </StackPanel>
                </GroupBox>
            </ScrollViewer>
        </Grid>
    </Window>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Collections.ObjectModel;
    using System.ComponentModel;

    namespace Sandbox
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                ObservableCollection<ConfigurationParameter> config = new ObservableCollection<ConfigurationParameter>();
                for (int i = 0; i < 10; i++)
                {
                    config.Add(new ConfigurationParameter { Name = "name_" + i, Description = "Description_" + i, Value = i.ToString() });
                }

                InitializeComponent();
                this.ConfigurationStackPanel.DataContext = config;           
            }
        }

        public class ConfigurationParameter
        {
            public string Name
            {
                get;
                set;
            }

            public string Value
            {
                get;
                set;
            }

            public string Description
            {
                get;
                set;
            }
        }
    }
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 22 Apr 2011 Link to this post

    Hello Greg,

    Thanks for pasting the sample code. Things are now clear .
    Since RadDataForm can not be fed with such ObservableCollection<ConfigurationParameter> , you may need will need to create an object instead. Since data is dynamic and properties may vary in count , this should be  dynamic.

    Such approach is demonstrated in this blogpost.It is demonstrated with RadGridView, but the principle is the same for RadDataForm .  Actually you can directly take the data table from the blogpost and use it in your code.

    In case you have difficulties implementing this approach , do not hesitate to contact me .

    Greetings,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top