User Profile
Daniel_Donnelly_Jr
Copper Contributor
Joined Dec 05, 2022
User Widgets
Recent Discussions
How does one databind a "Color function" that takes a parameter an already-bound object?
Here is the function I want to bind to: public Color DeviceStatusColor(Device device) { string colorKey; switch (device.Status) { case "Connected and OK state": colorKey = "DeviceConnectedAndOkState"; break; case "Not connected state": colorKey = "DeviceNotConnectedState"; break; case "Alarm state": colorKey = "DeviceAlarmState"; break; case "Error state": colorKey = "DeviceErrorState"; break; default: return new Color(0, 0, 0); } return (Color) Application.Current.Resources[colorKey]; } It sits in my DevicesViewModel.cs class. I would like to do something like "Stroke={Binding DeviceStatusColor, Parameter=Device}" in XAML, but I know that's not correct and there's no web articles on how to do this other than a Data-binding Converter. I think that's overkill. I just want to pass a parameter. If Converter is the way to go, then how would I accomplish that?802Views0likes1CommentRe: How do you add an image logo to the Title header of a ContentPage?
jhons122 That doesn't work: ``` <?xml version="1.0" encoding="UTF-8" ?> <ContentPage x:Class="CEDDashboard.View.SettingsDetailPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:viewmodel="clr-namespace:CEDDashboard.ViewModel" xmlns:local="clr-namespace:CEDDashboard.View" x:DataType="viewmodel:SettingsDetailViewModel" Title="{Binding Device.Name}"> <NavigationPage.TitleView> <StackLayout HorizontalOptions="Center" VerticalOptions="Center" Orientation="Horizontal"> <Image HorizontalOptions="Start" Source="app_logo.png" /> <Label HorizontalOptions="Start" VerticalTextAlignment="Center" Text="Device Detail Settings" FontSize="Small"/> </StackLayout> </NavigationPage.TitleView> <ContentPage.Content> <VerticalStackLayout> <Image HorizontalOptions="Start" Source="app_logo.png" /> <ScrollView BackgroundColor="{AppThemeBinding Light={StaticResource LightBackground}, Dark={StaticResource DarkBackground}}"> <Grid RowDefinitions="Auto,Auto,*"> <BoxView ``` The only image that is displayed is the one inside my content. The NavigationPage.TitleView trick doesn't show any image.3.9KViews0likes0Comments
Recent Blog Articles
No content to show