Skip to main content

Microsoft Silverlight

RIA Dynamic UI from EntitiesRSS Feed

(0)

trickypos
trickypos

Member

Member

0 points

4 Posts

RIA Dynamic UI from Entities

 

Hi,

I am trying to build a dynamic data management screen using RIA and Silverlight 3.0 and EF


The reason being I have over 60 tables to manage and wish to use a single screen to manage the CRUD operations for all of these tables. So far I have managed to create a XAML that contains;

A listBox

A DataForm

A few Buttons


I can load the Listbox using a dynamic query built from ;


Dim returnObject = Me.GetType.Assembly.CreateInstance(RootNameSpace & ".Web." & Name)


and the data loads OK and the selected item from the listbox can populate the Dataform also using reflection to build the Dataform contents and controls.


However I have a few issues I can not resolve


  1. How can I either extend the ria table class to include a “DisplayMemberPath” or even better set this in the attributes for the class to enable the list box to display the correct data lables.The “DisplayMemberPath” needs to be data driven as I do not wish to impliment a lookup as this is messy ( x 60 tables and growing ).

  2. The same principle applies for the Forign Keys in the Data Form for the Combo Boxes.

  3. When building the DataForm I use the below code to build the controls but is there a better way ( feels very lashy) .


I hope someone can help.


Regards,


Richard C




If _Table_Name <> "" Then

Dim _table = FindEntityByName(_Table_Name)

Dim Table_Info() As PropertyInfo = _table.GetType.GetProperties

Me.DataForm.Fields.Clear()

For Each item In Table_Info

If item.PropertyType.BaseType IsNot Nothing Then

If item.PropertyType.BaseType.Namespace = "System.Windows.Ria.Data" Then

Dim newddl As New DataFormComboBoxField

newddl.Binding = New Binding(item.Name)

newddl.FieldLabelContent = item.Name


Dim table As PropertyInfo

If item.Name.EndsWith("s") Then

table = myService.Service.GetType.GetProperty(item.Name)

Else

table = myService.Service.GetType.GetProperty(item.Name & "s")

End If


If table IsNot Nothing Then

Dim table_Value = table.GetValue(myService.Service, Nothing)

newddl.ItemsSource = table_Value

End If


Me.DataForm.Fields.Add(newddl)

Else

Dim newfield As New DataFormTextField

newfield.Binding = New Binding(item.Name)

newfield.FieldLabelContent = item.Name

Me.DataForm.Fields.Add(newfield)

End If


End If

Next


End If


  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities