Bug 46979 - Borders and color issues with custom controller (XF 2.3.2.127)
Summary: Borders and color issues with custom controller (XF 2.3.2.127)
Status: RESOLVED NORESPONSE
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.2
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-15 09:52 UTC by Paul Johnson
Modified: 2017-03-03 16:06 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Paul Johnson 2016-11-15 09:52:57 UTC
I have a very simple custom button (it puts a radius curve on the top of the button). I don't alter any properties in the custom class, just inherit Button

In the XAML I have the following

<local:CustomButton x:Name="btnDetails" BorderColor="Blue" BorderWidth="2" FontSize="14" VerticalOptions="CenterAndExpand" Text="{Binding Converter={StaticResource Language}, ConverterParameter=MyPatient_Details}" Clicked="Handle_Clicked" ClassId="0" WidthRequest="{Binding Converter={StaticResource WidthSize}, ConverterParameter=.3}" />
<local:CustomButton x:Name="btnAppointments" BorderColor="Blue" BorderWidth="2" FontSize="14" VerticalOptions="CenterAndExpand" Text="{Binding Converter={StaticResource Language}, ConverterParameter=MyPatient_Appointments}" Clicked="Handle_Clicked" ClassId="1" WidthRequest="{Binding Converter={StaticResource WidthSize}, ConverterParameter=.3}" />
<local:CustomButton x:Name="btnNotes" BorderColor="Blue" BorderWidth="2" FontSize="14" VerticalOptions="CenterAndExpand" Text="{Binding Converter={StaticResource Language}, ConverterParameter=MyPatient_Notes}" Clicked="Handle_Clicked" ClassId="2" WidthRequest="{Binding Converter={StaticResource WidthSize}, ConverterParameter=.3}" />

In my source class constructor, I put the initial colors for btnDetails so the background is purple and text is white with the following event to change the backgrounds

void Handle_Clicked(object sender, System.EventArgs e)
        {
            var btnClassId = ((CustomButton)sender).ClassId;
            var selectedTextColor = Color.White;
            var unselectedTextColor = Color.Black;
            var selectedBgColor = Color.Purple;
            var unselectedBgColor = Color.White;
            switch (btnClassId)
            {
                case "0":
                    if (currentTab != 0)
                    {
                        currentTab = 0;
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            btnDetails.TextColor = selectedTextColor;
                            btnDetails.BackgroundColor = selectedBgColor;
                            btnNotes.TextColor = btnAppointments.TextColor = unselectedTextColor;
                            btnNotes.BackgroundColor = btnAppointments.BackgroundColor = unselectedBgColor;
                        });
                    }
                    break;
                case "1":
                    if (currentTab != 1)
                    {
                        currentTab = 1;
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            btnAppointments.TextColor = selectedTextColor;
                            btnAppointments.BackgroundColor = selectedBgColor;
                            btnNotes.TextColor = btnDetails.TextColor = unselectedTextColor;
                            btnNotes.BackgroundColor = btnDetails.BackgroundColor = unselectedBgColor;
                        });
                    }
                    break;
                case "2":
                    if (currentTab != 2)
                    {
                        currentTab = 2;
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            btnNotes.TextColor = selectedTextColor;
                            btnNotes.BackgroundColor = selectedBgColor;
                            btnDetails.TextColor = btnAppointments.TextColor = unselectedTextColor;
                            btnDetails.BackgroundColor = btnAppointments.BackgroundColor = unselectedBgColor;
                        });
                    }
                    break;
            }
        }

When I run the view, btnDetails is the correct colour, but there are no borders around the button until it is clicked and the background on the first button never changes to white with black text - the others do.

=== Xamarin Studio Business ===

Version 6.2 (build 1358)
Installation UUID: f3d1a29c-1ba2-4a83-a193-1087efe91a85
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/dea12ad) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000309

=== NuGet ===

Version: 3.4.3.0

=== Xamarin.Profiler ===

Version: 0.24.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.1 (11544)
Build 8B62

=== Xamarin.iOS ===

Version: 10.4.0.4 (Xamarin Business)
Hash: 050f92b
Branch: master
Build date: 2016-11-04 21:35:33-0400

=== Xamarin.Mac ===

Version: 3.0.0.274 (Xamarin Business)

=== Xamarin.Android ===

Version: 7.0.99.160 (Xamarin Business)
Android SDK: /Users/PFJ/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 25
SDK Build Tools Version: 25

Java SDK: /usr
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 602001358
Git revision: 9af49bfd72f62e2e065ebd33d17822a6c6c6a10e
Build date: 2016-11-07 05:56:48-05
Xamarin addins: ac8224983fc10c74a5d78ea5a09c8d2b15868d5f
Build lane: monodevelop-lion-cycle9

=== Operating System ===

Mac OS X 10.12.1
Darwin iMac.local 16.1.0 Darwin Kernel Version 16.1.0
    Thu Oct 13 21:26:57 PDT 2016
    root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
Comment 1 adrianknight89 2016-11-15 17:39:06 UTC
Can you attach a repro instead?
Comment 2 Paul DiPietro [MSFT] 2017-03-03 16:06:09 UTC
Please reopen this if you can provide a reproduction. The XAML indicates there are some custom bindings and having to do guesswork makes investigating a possible cause more difficult.