Availability Seems Outta Control
-
Friday, June 29, 2012 3:09 PM
I have a ListDetails page that was behaving beautifully. I needed a property that showed the number of records when the DataControl_SeletionChanged event occurred, so I created the property "NumberInClass" and set it to equal the count of the records when the grid's selectionchanged fired. For no reason that I can figure out, none of the events in my EventsHandlers region fires now. The SiteRegistration_SelectionChanged event and ProgramRegistration_SelectionChanged works, but nothing else in the region does, and I mean nothing. I set break points on setting the priviate variables and I get nothing in the debugger. SitesListDetail_ControlAvailable event or the other events (that are not commented out) in the region don't fire. The debugger doesn't break on the variables being created either.
Any thoughts anyone? Thanks...
Imports System.Windows.Controls Imports System.Windows.Data Imports System.Text Imports System.Collections Namespace LightSwitchApplication Public Class SitesListDetail Private Const Data_Control As String = "ProgramRegistration" Private WithEvents _dataControl As DataGrid = Nothing Private _selectedCount As Integer '= 0 #Region " Event Handlers " Private Sub SitesListDetail_ControlAvailable(send As Object, e As ControlAvailableEventArgs) 'we know that the control is a grid, but we use TryCast, just in case _dataControl = TryCast(e.Control, DataGrid) 'if the cast failed, just leave, there's nothing more we can do here If (_dataControl Is Nothing) Then Return 'set the property on the grid that allows multiple selection _dataControl.SelectionMode = DataGridSelectionMode.Extended End Sub 'Private Sub Sites_SelectionChanged() 'Me.NumberInClass = Me.ProgramRegistration.Count 'End Sub 'Private Sub SiteRegistration_SelectionChanged() ' Me.NumberInClass = Me.ProgramRegistration.Count 'End Sub Private Sub DataControl_SelectionChanged() Handles _dataControl.SelectionChanged _selectedCount = _dataControl.SelectedItems.Count If _selectedCount > 0 Then Me.FindControl("AddNewAttendance").IsVisible = True Me.FindControl("Tardy").IsVisible = True Me.FindControl("ExcusedAbsence").IsVisible = True Me.FindControl("UnexcusedAbsence").IsVisible = True Me.FindControl("Rainout").IsVisible = True Me.NumberInClass = Me.ProgramRegistration.Count Else Me.FindControl("AddNewAttendance").IsVisible = False Me.FindControl("Tardy").IsVisible = False Me.FindControl("ExcusedAbsence").IsVisible = False Me.FindControl("UnexcusedAbsence").IsVisible = False Me.FindControl("Rainout").IsVisible = False End If End Sub #End Region
- Moved by Justin AndersonMicrosoft Employee, Moderator Saturday, June 30, 2012 11:32 AM Not extensibility (From:Visual Studio LightSwitch Extensibility)
All Replies
-
Saturday, June 30, 2012 11:32 AMModerator
I don't see anywhere in this code where you subscribe the SitesListDetail_ControlAvailable method as an event handler. It should look like this:
AddHandler Me.FindControl(SitesListDetail.Data_Control).ControlAvailable, AddressOf Me.SitesListDetail_ControlAvailable
either in your SitesListDetail_Created method or SitesListDetail_InitializeDataWorkspace method.Justin Anderson, LightSwitch Development Team
- Marked As Answer by w.darnellg.g Saturday, June 30, 2012 11:43 PM
-
Saturday, June 30, 2012 11:46 PMI am not sure if that line of code was accidentally removed or not, but I do know that everything was working prior to adding the property I mentioned. In any event, adding the code you suggested to the SitesListDetail_InitializeDataWorkspace method has everything performing as expected. Thank you so much for taking a look and sharing your insight.

