Binding Items Inside RadPanel

2 posts, 0 answers
  1. raghul
    raghul avatar
    11 posts
    Member since:
    Jul 2010

    Posted 03 Dec 2011 Link to this post

    Hi,
    I have two doubts to be clarified.
    1. How should I bind the textblock and the combo box which is found inside the radpanel?
    2. If I need to display 'N' number of RadPanelBarItems at run time should I need to do that using the for loop or is there any way to display the items?

    Please find my attached coding, Please let me know what is the mistake I have done??

    public partial class TestStepData : UserControl
       {
           IList<TestCase> lstTestCase = new List<TestCase>();
           IList<TestStepData1> lstTestStepData = new List<TestStepData1>();
           IList<Datas> lstDatas = new List<Datas>();
           IList<Field> lstField = new List<Field>();
           IList<KeyWords> lstKeyWords = new List<KeyWords>();
           public TestStepData()
           {
               InitializeComponent();
               BindTestCase();
           }
     
           public IList<KeyWords> BindKeyWords()
           {
               lstKeyWords.Add(new KeyWords("KeyWord Description One","KID 0001"));
               lstKeyWords.Add(new KeyWords("KeyWord Description Two", "KID 0002"));
               lstKeyWords.Add(new KeyWords("KeyWord Description Three", "KID 0003"));
               lstKeyWords.Add(new KeyWords("KeyWord Description Four", "KID 0004"));
               return lstKeyWords;
           }
     
           public IList<Field> BindFields()
           {
               lstField.Add(new Field("Field Description One", "Fid 0001"));
               lstField.Add(new Field("Field Description Two", "Fid 0002"));
               lstField.Add(new Field("Field Description Three", "Fid 0003"));
               return lstField;
           }
     
           public IList<Datas> Bindedata()
           {
               lstDatas.Add(new Datas("Data Description One", "Did 0001"));
               lstDatas.Add(new Datas("Data Description Two", "Did 0002"));
               lstDatas.Add(new Datas("Data Description Three", "Did 0003"));
               return lstDatas;
           }
     
           public IList<TestStepData1> BindStepData()
           {
               lstTestStepData.Add(new TestStepData1("Test Step To Execute One", "Description for Step to Execute One"));
               lstTestStepData.Add(new TestStepData1("Test Step To Execute Two", "Description for Step to Execute Two"));
               lstTestStepData.Add(new TestStepData1("Test Step To Execute Three", "Description for Step to Execute Three"));
               return lstTestStepData;
           }
     
           public IList<TestCase> BindTestCase()
           {
               lstTestCase.Add(new TestCase("TestCaseId One", "Desc Case Description One", BindStepData(), Bindedata(), BindFields(), BindKeyWords()));
               lstTestCase.Add(new TestCase("TestCaseId Two", "Desc Case Description Two", BindStepData(), Bindedata(), BindFields(), BindKeyWords()));
               lstTestCase.Add(new TestCase("TestCaseId Three", "Desc Case Description Three", BindStepData(), Bindedata(), BindFields(), BindKeyWords()));
               lstTestCase.Add(new TestCase("TestCaseId Four", "Desc Case Description Four", BindStepData(), Bindedata(), BindFields(), BindKeyWords()));
               lstTestCase.Add(new TestCase("TestCaseId Five", "Desc Case Description Five", BindStepData(), Bindedata(), BindFields(), BindKeyWords()));
               lstTestCase.Add(new TestCase("TestCaseId Six", "Desc Case Description Six", BindStepData(), Bindedata(), BindFields(), BindKeyWords()));
               return lstTestCase;
           }
       }
     
       public class KeyWords
       {
           public string KeyWordDescription { get; set; }
           public string KeyWordId { get; set; }
     
           public KeyWords()
           { }
     
           public KeyWords(string KDesc, string kId)
           {
               KeyWordDescription = KDesc;
               KeyWordId = kId;
           }
       }
     
       public class Field
       {
           public string FieldDescription { get; set; }
           public string FieldId { get; set; }
     
           public Field()
           {
     
           }
     
           public Field(string strFDesc, string strFId)
           {
               FieldDescription = strFDesc;
               FieldId = strFId;
           }
       }
     
       public class Datas
       {
           public string DatasDescription { get; set; }
           public string DataId { get; set; }
     
           public Datas()
           { }
     
           public Datas(string strDesc, string strid)
           {
               DatasDescription = strDesc;
               DataId = strid;
           }
       }
     
       public class TestStepData1
       {
           public string TestStepsToExecute { get; set; }
           public string TestStepsDescription { get; set; }
     
           public TestStepData1()
           {
     
           }
     
           public TestStepData1(string tstSTExecute, string tstDesc)
           {
               TestStepsToExecute = tstSTExecute;
               TestStepsDescription = tstDesc;
           }
       }
     
       public class TestCase
       {
           public string TestCaseId { get; set; }
           public string TestCaseDescription { get; set; }
           IList<TestStepData1> lstTestStepData = new List<TestStepData1>();
           IList<Datas> lstDatas = new List<Datas>();
           IList<Field> lstField = new List<Field>();
           IList<KeyWords> lstKeyWords = new List<KeyWords>();
     
           public TestCase()
           {
     
           }
     
           public TestCase(string strTestcaseid, string strTestcaseDesc, IList<TestStepData1> lTestStepData, IList<Datas> lDatas, IList<Field> lField, IList<KeyWords> lkeywords)
           {
               TestCaseId = strTestcaseid;
               TestCaseDescription = strTestcaseDesc;
               lstTestStepData = lTestStepData;
               lstDatas = lDatas;
               lstField = lField;
               lstKeyWords = lkeywords;
           }
       }

    <Grid x:Name="LayoutRoot" Background="White">
         <telerik:RadPanelBar x:Name="radPanelBar" VerticalAlignment="Stretch"
                     BorderBrush="#FFCBD8E8" BorderThickness="1 1 0 1" ItemsSource="{Binding TestCase}">
             <telerik:RadPanelBarItem IsExpanded="True">
                 <telerik:RadPanelBarItem.Header>
                     <StackPanel Orientation="Horizontal">
                         <TextBlock x:Name="txtTestCaseHeading" FontStyle="Italic" FontSize="12" Text="Test Case"></TextBlock>
                     </StackPanel>
                 </telerik:RadPanelBarItem.Header>
                 <telerik:ListBox BorderThickness="0" BorderBrush="Transparent">
                     <Grid>
                         <Grid.RowDefinitions>
                             <RowDefinition Height=".5*"></RowDefinition>
                             <RowDefinition Height="*"></RowDefinition>
                             <RowDefinition Height=".3*"></RowDefinition>
                         </Grid.RowDefinitions>
                         <StackPanel Grid.Row="0" Orientation="Horizontal" Height="30">
                             <TextBlock x:Name="txtTestCaseid" FontStyle="Normal" FontSize="10" Text="{Binding TestCaseId}"></TextBlock>
                             <TextBlock Width="15"></TextBlock>
                             <TextBlock x:Name="txtTestCaseDescription" FontStyle="Normal" FontSize="10" Text="{Binding TestCaseDescription}"></TextBlock>
                         </StackPanel>
                         <StackPanel Grid.Row="1" Orientation="Horizontal">
                             <TextBlock x:Name="txtTestStepDataid" FontStyle="Normal" FontSize="10" Text="Test Step Data Id"></TextBlock>
                             <TextBlock Width="15"></TextBlock>
                             <TextBlock x:Name="txtTestStepDataDescription" FontStyle="Normal" FontSize="10" Text="Test Step Data Description"></TextBlock>
                         </StackPanel>
                         <StackPanel Grid.Row="2" Orientation="Horizontal">
                             <telerik:RadComboBox x:Name="RadComboBox1" ItemsSource="{Binding KeyWordDescription}" Width="100" DisplayMemberPath="KeyWordDescription"></telerik:RadComboBox>
                             <telerik:RadComboBox x:Name="RadComboBox2" ItemsSource="{Binding FieldDescription}" Width="100" DisplayMemberPath="FieldDescription"></telerik:RadComboBox>
                             <telerik:RadComboBox x:Name="RadComboBox3" ItemsSource="{Binding DatasDescription}" Width="100" DisplayMemberPath="DatasDescription"></telerik:RadComboBox>
                         </StackPanel>
                     </Grid>
                 </telerik:ListBox>
             </telerik:RadPanelBarItem>
         </telerik:RadPanelBar>
     </Grid>


    Regards,

    Raghul
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 07 Dec 2011 Link to this post

    Hello Raghul,

     I made many modifications in your XAML and created a ViewModel class so that the scenario is closer to a typical MVVM approach. Could you please examine it and let us know if it satisfies you?

    Regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top