Creating a Global Style that specifies the BorderStyle

3 posts, 1 answers
  1. Greg
    Greg avatar
    2 posts
    Member since:
    Feb 2018

    Posted 09 Apr 2018 Link to this post

    Hi everyone,

    I'm trying to create a global style so that all RadEntry controls in my application have the same look and feel.

    I'd like the CornerRadius of the entry controls to be 0 and to specify a border color.

    I'm having issues figuring out how to specify the BorderStyle values in my global style.

    This is what I've tried so far and none of my border style values were applied:

    <OnPlatform x:Key="EntryPadding" x:TypeArguments="Thickness">
        <On Platform="iOS" Value="10,10,0,20" />
        <On Platform="Android,UWP" Value="10,10,0,10" />
    </OnPlatform>
     
    <Style x:Key="EntryBorderStyle" TargetType="telerikInput:BorderStyle">
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="BorderColor" Value="#808080" />
        <Setter Property="BorderThickness" Value="5" />
    </Style>
     
    <Style TargetType="telerikInput:RadEntry">
        <Setter Property="Padding" Value="{StaticResource EntryPadding}" />
        <Setter Property="BorderStyle" Value="{StaticResource EntryBorderStyle}"/>
    </Style>

     

    Anyone have any ideas where I might be going wrong?

    Thanks,

    Greg

  2. Answer
    Lance | Technical Support Engineer, Principal
    Admin
    Lance | Technical Support Engineer, Principal avatar
    1002 posts

    Posted 09 Apr 2018 Link to this post

    Hi Greg,

    BorderStyle is an object you need to instantiate, it's not an inherited or implicit style you can override in a Style definition. This is also the case for all of the other UI for Xamarin controls that have Style properties (e.g. DataGrid's RowStyle or AlternateRowStyle).

    Solution

    To fix the issue you're having, create an instance of BorderStyle as a StaticResource for your implicit style: 

    <OnPlatform x:Key="EntryPadding" x:TypeArguments="Thickness">
        <On Platform="iOS" Value="10,10,0,20" />
        <On Platform="Android,UWP" Value="10,10,0,10" />
    </OnPlatform>
                 
    <input:BorderStyle x:Key="EntryBorderStyle"
              CornerRadius="0"
              BorderColor="#808080"
              BorderThickness="5"/>
      
    <Style TargetType="input:RadEntry">
        <Setter Property="Padding" Value="{StaticResource EntryPadding}" />
        <Setter Property="BorderStyle" Value="{StaticResource EntryBorderStyle}"/>
    </Style>

    Here is the result at runtime on Android with two RadEntry controls on a nested page:




    Further Assistance

    If you have any further issues, or would like assistance from the UI for Xamarin support team, please open a support ticket and attach the problematic code so that we can investigate directly.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Greg
    Greg avatar
    2 posts
    Member since:
    Feb 2018

    Posted 09 Apr 2018 in reply to Lance | Technical Support Engineer, Principal Link to this post

    Perfect, thanks Lance!
Back to Top