.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,066 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I have a Label that I want to show a value when returned from the database otherwise I want to show the word Add I tried Converter as below but not working.
<ContentPage.Resources>
<local:MyProfileLabelConverter x:Key="MyProfileLabelConverter" />
</ContentPage.Resources>
Here is my Label:
<Label x:Name="LabelMyHair" Text="{Binding Source={x:Reference .}, Path=Text, Converter={StaticResource MyProfileLabelConverter}}" VerticalOptions="Center" />
and this is my Converter:
public class MyProfileLabelConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (string.IsNullOrWhiteSpace((string)value)) return "Add";
else return value;
// return (string)value == "Add" ? IconFont.IconAdd : IconFont.IconEdit;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();// oneway binding, this method will not be called.
}
Thank you Jassim
I think you can use a data trigger https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/triggers?view=net-maui-7.0#data-triggers