Changes

Traits

107 bytes removed, 27 April
/* XAML Customizing / UI Integration */
== XAML Customizing / UI Integration ==
To display traits in custom XAML templates, make them editable, or create new ones, standard {{UBIK}} controls like <code>EvalExpression</code> or <code>SfListViewExt</code> are used. === 1. Pure Display of All Displaying all Traits (in a List View(read-only) ===If you simply want to display all traits of an object, you can bind directly to <code>Content.Traits</code>. Here, it is combined with the Syncfusion ListView (<code>SfListViewExt</code>):{{Attention| With that you Bindings persist only bind on DataModel level (which means changes on viewmodel ViewModel level are only visible after saving).}}
<syntaxhighlight lang="xml">
xmlns:controls="clr-namespace:UBIK.MAUI.Controls;assembly=UBIK.MAUI"
 
<controls:SfListViewExt ItemsSource="{Binding Content.Traits}">
<controls:SfListViewExt.ItemTemplate>
<DataTemplate>
<Border Padding="10,8" BackgroundColor="#FAFAFA" Stroke="#E0E0E0" StrokeShape="RoundRectangle 8">
<Grid ColumnDefinitions="0.4*, 0.6*">
<Label Grid.Column="0" FontAttributes="Bold" Text="{Binding Name}" VerticalTextAlignment="Center" /> <Label Grid.Column="1" Text="{Binding Value, TargetNullValue='Not found'}" TextColor="#555555" VerticalTextAlignment="Center" />
</Grid>
</Border>
</DataTemplate>
</controls:SfListViewExt.ItemTemplate>
</syntaxhighlight>
=== 2. Edit Editing a Single single Trait or Property (via ValueAccessors) ===To dynamically query and edit a specific trait, use the an <code>EvalExpression</code> with the <code>ValueAccessors</code> contextContext should be used. The <code>TwoWay</code> binding ensures that changes are written directly back to the ViewModel.
<syntaxhighlight lang="xml">
xmlns:controls="clr-namespace:UBIK.MAUI.Controls;assembly=UBIK.MAUI"
 
<controls:EvalExpression x:Name="EvalS2" Context="{Binding ValueAccessors}" Expression="Context[P0]">
<controls:EvalExpressionParameter Name="P0" Value="{Binding Path=Text, Source={x:Reference S2NameInput}}" />
</controls:EvalExpression>
<Entry x:Name="S2NameInput" Placeholder="Enter name..." />
<Entry x:Name="S2ValueInput" Text="{Binding Result.Value, Source={x:Reference EvalS2}, Mode=TwoWay, FallbackValue='Not found'}" />
</syntaxhighlight>
=== 3. Delete Deleting a Trait ===Deleting a trait does not require a dedicated command. Instead, it uses an event behavior can be used to directly invoke the <code>Delete</code> method on the evaluator's result..
<syntaxhighlight lang="xml">
xmlns:behaviors="clr-namespace:UBIK.MAUI.Behaviors;assembly=UBIK.MAUI" <Button Text="Delete" BackgroundColor="#D32F2F" TextColor="White">
<Button.Behaviors>
<behaviors:EventHandlerBehavior EventName="Clicked">
</syntaxhighlight>
=== 4. Create Creating or Overwrite overwriting a Trait (via SetValueCommand) ===To create traits entirely from scratch (or to explicitly overwrite an existing value), the <code>SetValueCommand</code> of the <code>ContentViewModel</code> is should be used. A <code>KeyValueList</code> must be passed to this commandCommand.
<syntaxhighlight lang="xml">
296
edits