LightSwitch Application WEB interface

Discussion in 'Lightswitch Integration' started by JeanM, Mar 5, 2014.

  1. JeanM

    JeanM New Member

    How can hide or minimize Lightswitch menu or ribbon bar, because somtimes there are very large place on the screen?
  2. avreporter

    avreporter Administrator Staff Member

    It is not one click in Lightswitch, you have to write some codes.
  3. avreporter

    avreporter Administrator Staff Member

    You have to create Helper class in Lightswitch, it is included this functions.

    Visual Basic Code:

    Imports Microsoft.LightSwitch.Runtime.Shell.Implementation.Standard
    Imports System.Windows
    Imports System.Windows.Media
    Imports System.Windows.Browser
    Imports Microsoft.LightSwitch.Threading
    Namespace LightSwitchApplication
    Public Class Helpers
    ''' <summary>
    ''' Hide the mnain menu altogether
    ''' </summary>
    Public Shared Sub HideMenu()
    Dispatchers.Main.Invoke(Function()
    MainMenu.Visibility = Visibility.Collapsed
    End Function)
    End Sub
    ''' <summary>
    ''' Collapse the main menu
    ''' </summary>
    Public Shared Sub CollapseMenu()
    Dispatchers.Main.Invoke(Function()
    MainMenu.IsExpanded = False
    End Function)
    End Sub
    ''' <summary>
    ''' Hide the RibbonBar altogether
    ''' </summary>
    Public Shared Sub HideRibbonBar()
    Dispatchers.Main.Invoke(Function()
    RibbonBar.Visibility = Visibility.Collapsed
    End Function)
    End Sub
    ''' <summary>
    ''' Collapse the toolbar altogether
    ''' </summary>
    Public Shared Sub CollapseRibbonBar()
    Dispatchers.Main.Invoke(Function()
    RibbonBar.IsCompressed = True
    End Function)
    End Sub
    ''' <summary>
    ''' Get the Main Menu Control
    ''' </summary>
    Private Shared ReadOnly Property MainMenu() As NavigationView
    Get
    Dim root = System.Windows.Application.Current.RootVisual
    Return DirectCast(FindControlByName(root, "NavigationView"), NavigationView)
    End Get
    End Property
    ''' <summary>
    ''' Get the Main RibbonBar Control
    ''' </summary>
    Private Shared ReadOnly Property RibbonBar() As RibbonCommandBar
    Get
    Dim root = System.Windows.Application.Current.RootVisual
    Return DirectCast(FindControlByName(root, "HomeTabItem"), RibbonCommandBar)
    End Get
    End Property
    ''' <summary>
    ''' Find a control with the specified Name (recursively) - returns null if not found.
    ''' </summary>
    Public Shared Function FindControlByName(control As DependencyObject, name As String) As DependencyObject
    If control Is Nothing Then
    Return Nothing
    End If
    If control.GetValue(FrameworkElement.NameProperty) IsNot Nothing AndAlso control.GetValue(FrameworkElement.NameProperty).ToString() = name Then
    Return control
    End If
    ' When it is a ScrollViewer we need to use the .Content property
    If control.[GetType]().Equals(GetType(System.Windows.Controls.ScrollViewer)) Then
    control = TryCast(DirectCast(control, System.Windows.Controls.ScrollViewer).Content, FrameworkElement)
    End If
    For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(control) - 1
    Dim child = FindControlByName(VisualTreeHelper.GetChild(control, i), name)
    If child IsNot Nothing Then
    Return child
    End If
    Next
    Return Nothing
    End Function
    End Class
    End Namespace
  4. avreporter

    avreporter Administrator Staff Member

    After that you can copy this code to RUN event of Screen in Lightswitch application:

    Private Sub Fogyasztásmérők_Run(ByRef handled As Boolean)
    Helpers.CollapseMenu()
    Helpers.CollapseRibbonBar()
    'Helpers.HideMenu()
    'Helpers.HideRibbonBar()
    handled = False
    End Sub

Share This Page