Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Samples/WpfExample/BusinessLibrary/PersonEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public int Id
set { SetProperty(IdProperty, value); }
}

public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name), "Person Name");
[Required]
public string Name
{
Expand Down
4 changes: 3 additions & 1 deletion Samples/WpfExample/WpfExample/Pages/PersonEditPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:csla="clr-namespace:Csla.Xaml;assembly=Csla.Xaml"
xmlns:businesslibrary="clr-namespace:BusinessLibrary;assembly=BusinessLibrary" d:DataContext="{d:DesignInstance Type=businesslibrary:PersonEdit}"
mc:Ignorable="d" Loaded="UserControl_Loaded"
d:DesignHeight="450" d:DesignWidth="800">
Expand All @@ -16,7 +17,8 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Name" Grid.Row="0" Grid.Column="0" />
<csla:PropertyInfo Property="{Binding Name}" x:Name="NameInfo" />
<Label Content="{Binding ElementName=NameInfo, Path=FriendlyName}" Grid.Row="0" Grid.Column="0" />
<TextBox Text="{Binding Name}" Grid.Row="0" Grid.Column="1" Width="200" />
<Button Content="Save" Grid.Row="1" Grid.Column="1" IsEnabled="{Binding IsSavable}" Click="SavePerson" />
</Grid>
Expand Down
23 changes: 23 additions & 0 deletions Source/Csla.Xaml.Shared/PropertyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,28 @@ void source_BusyChanged(object? sender, BusyChangedEventArgs e)

#endregion

#region FriendlyName

/// <summary>
/// Gets the friendly name for the property.
/// </summary>
[Category("Property Status")]
public string FriendlyName
{
get
{
if (Source != null && !string.IsNullOrWhiteSpace(BindingPath))
{
var pi = Core.FieldManager.PropertyInfoManager.GetRegisteredProperty(Source.GetType(), BindingPath);
if (pi != null)
return pi.FriendlyName;
}
return string.Empty;
}
}

#endregion

#region Error/Warn/Info Text

/// <summary>
Expand Down Expand Up @@ -854,6 +876,7 @@ orderby r.Severity
OnPropertyChanged(nameof(ErrorText));
OnPropertyChanged(nameof(WarningText));
OnPropertyChanged(nameof(InformationText));
OnPropertyChanged(nameof(FriendlyName));
}

#endregion
Expand Down
Loading