I am using treeview for silverlight. and i am trying to pass values to it. the structure of the data comming from the WCF is shown below
[
DataContract]
public class QPQuestionSummary
{
string _LessonObjectiveTitle = "";
List<QuestionSummary> _QuestionTitle = new List<QuestionSummary>();
[
DataMember]
public string LessonObjectiveTitle
{
get { return _LessonObjectiveTitle; }
set { _LessonObjectiveTitle = value; }
}
[
DataMember]
public List<QuestionSummary> QuestionTitle
{
get { return _QuestionTitle; }
set { _QuestionTitle = value; }
}
}
[
DataContract]
public class QuestionSummary
{
public QuestionSummary(String Question_Title)
{
QuestionTitle = Question_Title;
}
public QuestionSummary()
{
}
[
DataMember]
public string QuestionTitle
{
get;
set;
}
}
public List<QPQuestionSummary> QuestionPoolSummary(int StatSlidId, string ConnectionString)
{
List
<QPQuestionSummary> _Summary = new List<QPQuestionSummary>();
//some codes here
return _Summary
}
The data template for the Treeview is show below
<UserControl.Resources>
<telerik:HierarchicalDataTemplate x:Key="QuestionSummary" ItemsSource="{Binding ItemsSelected}">
<TextBlock Text="{Binding QuestionName}" Foreground="Green" FontStyle="Italic" />
</telerik:HierarchicalDataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<telerikNavigation:RadTreeView Margin="8,8,64,8" x:Name="tSummary"
ItemTemplate="{StaticResource QuestionSummary}">
</telerikNavigation:RadTreeView>
</Grid>
and the class in the silverlight to catch the data is shown below
public
class SummaryQuestions
{
public SummaryQuestions(string Name)
{
QuestionName = Name;
ItemsSelected =
new List<SummaryItems>();
}
public string QuestionName
{
get;
set;
}
public List<SummaryItems> ItemsSelected
{
get;
set;
}
}
public class SummaryItems
{
public SummaryItems(string Name)
{
ItemName = Name;
}
public string ItemName
{
get;
set;
}
}
public class SummaryQuestionList : List<SummaryQuestions>
{
public SummaryQuestionList()
{
App _app = (App)Application.Current;
QPQuestions.
QPQuestionsClient _Summary = new QuestionPoolSL.QPQuestions.QPQuestionsClient();
_Summary.QuestionPoolSummaryAsync(_app.StatSlideID(), _app.ConnectionString());
_Summary.QuestionPoolSummaryCompleted +=
new EventHandler<QuestionPoolSL.QPQuestions.QuestionPoolSummaryCompletedEventArgs>(Summary_QuestionPoolSummaryCompleted);
}
protected void Summary_QuestionPoolSummaryCompleted(object sender, QuestionPoolSL.QPQuestions.QuestionPoolSummaryCompletedEventArgs e)
{
SummaryQuestions y;
foreach (QPQuestionSummary x in e.Result)
{
Add(y =
new SummaryQuestions(x.LessonObjectiveTitle));
y.ItemsSelected.Add(
new SummaryItems(x.QuestionTitle[0].QuestionTitle));
}
}
}
and in the load part of the page i try to do this.
try
{
tSummary.ItemsSource =
new SummaryQuestionList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK);
}
but there are no items displayed....
the treeview control is not that friendly to use. can you make a documentation how to use it. I mean a detailed one.
Thaks a lot....