Borbin the 🐱

Xamarin - change image for ImageButton

21 April 2020


For my project I'm working on I needed a button with an image that needs to be changed according to a state variable using XAML and MVVM. In this case, the changing image for a start / stop button:

Add the ImageButton to the MainPage.xaml:

<ContentPage.BindingContext>
    <local:MainPageViewModel />
</ContentPage.BindingContext>

<StackLayout>
    <ImageButton Source="{Binding StartStopImage}"
                 Command="{Binding StartStopCommand}"
                 WidthRequest="50"
                 HeightRequest="50"
                 HorizontalOptions="Center"
                 VerticalOptions="Center" >
    </ImageButton>

Add the implementation for MVVM:

    public MainPageViewModel()
    {
        StartStopCommand = new Command(async () => await StartStop());
    }


    public async Task StartStop()
    {
        recordEnabled = !recordEnabled;

        StartStopImage = recordEnabled ? "stop.png" : "start.png";
    }

    public Command StartStopCommand { get; }

    private string startStopImage = "stop.png";
    public string StartStopImage
    {
        get => startStopImage;
        set
        {
            startStopImage = value;
            OnPropertyChanged(nameof(StartStopImage));
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

Engineering Pi Day

22 Juli 2019


It was in one of the first physics courses when the Prof used 22/7 in an equation as an approximation. Within a few steps, he calculated the result on the board, leaving us students astounding about this.

So simple, and yet so close:

22 / 7 = 3,1̅4̅2̅8̅5̅7

𝜋 = 3,14159265358

22 / 7 - 𝜋 ≈ 0,00126

The math department would not had approved this, but not us engineers!


Dragonfly landed safely

06 Juli 2019


Dragonfly made it savely to our garden in the middle of the hot weather.

Captains view


Dragonfly landed safely

06 Juli 2019


Dragonfly made it savely to our garden in the middle of the hot weather.

Captains view


Overflow valve for CJ750 / M72 final drive

15 Mai 2019


The amount of oil in final drive of the CJ750 / M72 motorcycle needs to be very precise, otherwise the oil is pushed out through the main seal. The reason for this is the small volume of the final drive gear. Even the slightest overfilling push out oil when the final drive gets warm during driving.
To solve the problem, I had installed a small cylindric chamber (1) to collect the oil. But there was still some oil splashed out of the breathing hole so I added another chamber on top of it (2).

With the recommended 0.15l oil, there was still some splashing. Especially driving uphill.
To get around this problem once and for all, I have made an even larger chamber (3) holding a fair amount of oil that allows a slight overfilling to ensure I have always enough oil.
The thread size is M14x1.5.


Neutral switch for CJ750 / M72

27 April 2019


The CJ750 / M72 motorcycle does not have a neutral indicator. With a simple switch extension to the gearbox lever you can add a neutral indicator.

It starts with the switch plate that gets attached to the gearbox lever cut out from stainless steel.

Now with the parts fabricated, the switch holder gets attached to the gearbox.

You can use any ball switch for automotive purpose.

The neutral lamp is added to a simple mini dashboard, that also contains the high beam and oil lamp.


Neuere Beiträge →← Vorherige Beiträge