You are here:   Forum
Register   |  Login

Forum Notice

This Forum is ARCHIVE only
For LightSwitch questions,
please use the official forums at:

http://social.msdn.microsoft.com/forums/en-US/lightswitch/threads


Forums

Rounding Button Corners
Last Post 28 Mar 2012 12:46 PM by kbrownfield. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
KirkUser is Offline
New Member
New Member
Send Private Message
Posts:4
Avatar

--
21 Mar 2012 06:27 PM
    Does anyone know how to round the corners of Lightswitch buttons?  By buttons, I mean the regular buttons in a screen, not the command bar buttons on the ribbon control nor the buttons in a Datagrid.  I believe the normal way would be to create a theme containing a implicit style for TargetType="Button" and a ControlTemplate with an outer Border using CornerRadius. I tried that with a style for Button in Jan Van Der Haegen's ExtensionsMadeEasy. I also tried it using my own theme extension. But neither will actually change the style for the buttons in a Lightswitch project--I still get the same ole standard rectangular Lightswitch buttons.

    Finally, I tried creating my own button control extension and, of course, I can certainly set a specific style for it, but I would like it to use the selected Lightswitch theme for brushes, but I can't figure out how to reference a dynamic theme's resource dictionary either.

    Can anyone point me in the right direction?  Any idears would be greatly appreciated.
    KirkUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:4
    Avatar

    --
    28 Mar 2012 12:46 PM
    I finally figured out how to get my Lightswitch button corners rounded.  With a little prompting from Derek Spurlock (if you don't already have the Spursoft Lightswitch Extensions, go get them!), I discovered that if you want to provide style resources beyond colors and fonts, you must have a class that implements IThemeExtension.

    If you follow Microsoft's Walkthrough: Creating a Theme Extension, you will find that you start with a theme XAML file that contains the fonts and color resources for your theme.  You will also find a theme class implementing ITheme that looks something like this:

    Imports System
    Imports System.ComponentModel.Composition
     
    Imports Microsoft.LightSwitch.Theming
     
    Namespace Presentation.Themes
     
        <Export(GetType(ITheme))>
        <Theme(MyTheme.ThemeId, MyTheme.ThemeVersion)>
        Friend Class MyTheme
            Implements ITheme
     
    #Region "ITheme Members"
     
            Public ReadOnly Property ColorAndFontScheme As Uri Implements ITheme.ColorAndFontScheme
                Get
                    Return New Uri("/MyThemeExtension.Client;component/Presentation/Themes/MyTheme.xaml", UriKind.Relative)
                End Get
            End Property
     
            Public ReadOnly Property Id As String Implements ITheme.Id
                Get
                Return MyTheme.ThemeId
                End Get
            End Property
     
            Public ReadOnly Property Version As String Implements ITheme.Version
                Get
                Return MyTheme.ThemeVersion
                End Get
            End Property
     
    #End Region
     
    #Region "Constants"
     
            Friend Const ThemeId As String = "MyThemeExtension:MyTheme"
            Friend Const ThemeVersion As String = "1.0"
     
    #End Region
     
        End Class
     
    End Namespace

    You can then add a very basic button style with rounded corners to the bottom of your theme xaml file:

    <Style TargetType="Button" x:Key="DefaultButtonStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border Name="ButtonBorder"
                           CornerRadius="4"
                           BorderBrush="{StaticResource ButtonBorderBrush}"
                           Background="{StaticResource ButtonBackgroundBrush}">
                        <ContentPresenter Content="{TemplateBinding Content}"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Center"/>
                    < /Border>
                < /ControlTemplate>
            < /Setter.Value>
        < /Setter>
    < /Style>
     
    <Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}" />


    But if you run and test your extension now, the buttons in your test application will be unaffected by your added style.  To have your style used, you must add a new class to your theme_extension.client project that implements IThemeExtension:

    Imports System.ComponentModel.Composition
    Imports Microsoft.LightSwitch.Theming
     
    Namespace Presentation.Themes
     
        <Export(GetType(IThemeExtension))>
        <ThemeExtension(MyTheme.ThemeId)>
        Friend Class MyStyle
            Implements IThemeExtension
     
            Public Function GetControlStyleResources(themeId As String, themeVersion As String, modules As IEnumerable(Of Microsoft.LightSwitch.Model.IModuleDefinition)) As IEnumerable(Of Uri) Implements IThemeExtension.GetControlStyleResources
                Return New List(Of Uri) From {New Uri("/MyThemeExtension.Client;component/Presentation/Themes/MyTheme.xaml", UriKind.Relative)}
            End Function
        End Class
     
    End Namespace

    Now when you run and test your extension you will see that the buttons have the rounded-corner style!

    If you prefer, as I do, to use ExtensionsMadeEasy so you can modify your theme from inside your Lightswitch application, change the theme class to inherit from EasyThemeWithExtensionExporter instead of EasyThemeExporter and implement IThemeExtension:

    Imports ExtensionsMadeEasy.ClientAPI.Theme
    Imports Microsoft.LightSwitch.Theming
    Imports System.ComponentModel.Composition
     
    Namespace LightSwitchApplication
     
        Public Class MyTheme
            Inherits EasyThemeWithExtensionsExporter(Of MyTheme, MyTheme)
            Implements ITheme, IThemeExtension
     
            Public ReadOnly Property ColorAndFontScheme As Uri Implements ITheme.ColorAndFontScheme
                Get
                    Return New Uri(String.Format("/{0};component/Theme/{1}", Me.GetType.Assembly.FullName.Split(",")(0), "MyTheme.xaml"), UriKind.Relative)
                End Get
            End Property
     
            Public ReadOnly Property Id As String Implements ITheme.Id
                Get
                    Return "My Theme"
                End Get
            End Property
     
            Public ReadOnly Property Version As String Implements ITheme.Version
                Get
                    Return "1.0"
                End Get
            End Property
     
            Public Function GetControlStyleResources(themeId As String, themeVersion As String, modules As IEnumerable(Of Model.IModuleDefinition)) As IEnumerable(Of Uri) Implements IThemeExtension.GetControlStyleResources
                Return New List(Of Uri) From {New Uri(String.Format("/{0};component/Theme/{1}", Me.GetType.Assembly.FullName.Split(",")(0), "MyTheme.xaml"), UriKind.Relative)}
            End Function
     
        End Class
     
    End Namespace

    Either method will allow you to use your own styles for the buttons in Lightswitch.

    Kirk
    You are not authorized to post a reply.


    Latest Microsoft Visual Studio LightSwitch Forum Threads That Have Answers

    I've been working on a sample LS app using the latest VS 2013 updates.  Intrinsic database and HTML client. I have an Azure account I just signed up for and am trying to get this in the cloud as easily as possible.  At this stage security etc have no role in the app.  Could someone point me to a page/blog/how-to on the best way of doing this?  I've been reading up and it seems I have to right-click the server and client apps separately and tell them to publish to Azure?  Is there a solution-wide way of publishing both or a best-practice for doing each? In VS 2013 I'm being prompted for all kinds of Azure/Windows installers when I try to publish.  Not sure which of those I need specifically-- by that I mean I see options for Azure/Node and Azure/PHP publishing in the list of options, which I certainly don't need. And all told the options all add up to 450MB for me to download, so I'd like to keep the footprint as small as possible. 
    Read more...

    I'm writing a Lightswitch HTML app that allows users to upload and view an image associated with a person. I've split the image out into it's own table and given it a 0.1 - 1 relationship with the Person table with the idea that if I don't include the image in the Person browse screen, my records would load much faster. Am I correct in this assessment or is Lightswitch loading the image anyway because of the relationship I declared with the Person table? (I'm not familiar with the data envelope choice Lightswitch makes.) Also, if it is loading the image anyway, then how would you recommend I ensure screen responsiveness for a Person Browse screen? Thanks. - Mike
    Read more...

    Getting started with RIA
    4/11/2014 4:09 PM
    I'm still baffled by RIA. Never done anything with WCF and running into limitations of having to return data in exact shape as entities. have worked around some of these with SQL views due to time limitations.  I have a few dumb questions. I read many of the links about lightswitch and RIA, but don't understand much of the terminology (e.g. Domain services), so I'm lost almost straight away. I'm willing to buy a book or take a course on plural sight or wherever, but want to make sure i choose the right one as there are very few books specific to LS and I don't want to waste time learning the wrong subject. I have a desktop silverlight app that's deployed via a UNC path. What's required to use RIA? I'm assuming it's going to involve having to use IIS and creating a WCF service(?) on the IIS server to consume the http calls. Or have I got completely wrong, is RIA services something that runs in the silverlight app (and still sends call to SQL server --not via
    Read more...

    Hello, I am using LightSwitch HTML client (March 2014 Update). I have an edit screen and I want the user to stay on this screen after the save button is used. A possible solution would be to use the "afterClosed" option when navigate to the edit screen. Is there a more elegant solution that will help me to accomplish this requirement without navigate to the browse screen and then go back to the edit screen? Regards, Martin
    Read more...

    Hi LightSwitch Team, It is possible to build an Wix Installer for a LightSwitch Application after the LightSwitch project was builded with TFS? Can you give me a good link to start the work? I have no experience with WIX. Many thanks.
    Read more...

    1234

    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation