TemplateSelector végre jó!
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="WorkFlowCheck.MAUI.Pages.BaseStock.CheckPoints.CheckPointEditPage"
|
x:Class="WorkFlowCheck.MAUI.Pages.BaseStock.CheckPoints.CheckPointEditPage"
|
||||||
|
xmlns:local="clr-namespace:WorkFlowCheck.MAUI.Pages.BaseStock.CheckPoints"
|
||||||
Title="{Binding CheckPointDTO.ShortName}">
|
Title="{Binding CheckPointDTO.ShortName}">
|
||||||
<StackLayout Padding="20">
|
<StackLayout Padding="20">
|
||||||
<!-- Cím: Edit Item -->
|
<!-- Cím: Edit Item -->
|
||||||
@@ -27,18 +28,113 @@
|
|||||||
<Button Text="Cancel" Command="{Binding CancelCommand}" Grid.Column="2"/>
|
<Button Text="Cancel" Command="{Binding CancelCommand}" Grid.Column="2"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Label Text="Ellenőrzési feladatok" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="Center" />
|
<Label Text="Ellenőrzési feladatok" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="Center" />
|
||||||
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" CornerRadius="2">
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
<CollectionView x:Name="CheckPointCheckListRows" HeightRequest="440">
|
<CollectionView x:Name="CheckPointCheckListRows"
|
||||||
<CollectionView.ItemTemplate>
|
HeightRequest="440"
|
||||||
<DataTemplate>
|
|
||||||
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" CornerRadius="2">
|
ItemTemplate="{StaticResource AnswerTemplateSelector}">
|
||||||
<StackLayout>
|
<CollectionView.EmptyView>
|
||||||
<Label Text="{Binding OperationDescription}" FontSize="16" FontAttributes="Bold" />
|
<Label Text="Nincsenek feladatok." HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||||
</StackLayout>
|
</CollectionView.EmptyView>
|
||||||
</Frame>
|
|
||||||
</DataTemplate>
|
|
||||||
</CollectionView.ItemTemplate>
|
|
||||||
</CollectionView>
|
</CollectionView>
|
||||||
</Frame>
|
</Frame>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<DataTemplate x:Key="I_N_Template">
|
||||||
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
|
<Grid ColumnSpacing="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Text="{Binding OperationDescription}" BackgroundColor="LightBlue" Grid.Column="0" />
|
||||||
|
<Grid Grid.Column="1" ColumnDefinitions="*,*">
|
||||||
|
<Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center"/>
|
||||||
|
<Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Frame>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Key="P_Template">
|
||||||
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
|
<Grid ColumnSpacing="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
|
||||||
|
<Grid Grid.Column="1" ColumnDefinitions="*,*">
|
||||||
|
<Label Text="Fénykép készítése szükséges" Grid.Column="0" HorizontalTextAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Frame>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Key="SI_N_Template">
|
||||||
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
|
<Grid ColumnSpacing="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
|
||||||
|
<Grid Grid.Column="1" ColumnDefinitions="*,*">
|
||||||
|
<Label Text="I" Grid.Column="0" BackgroundColor="Yellow" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
<Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Frame>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Key="I_SN_Template">
|
||||||
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
|
<Grid ColumnSpacing="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
|
||||||
|
<Grid Grid.Column="1" ColumnDefinitions="*,*">
|
||||||
|
<Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
<Label Text="N" Grid.Column="1" BackgroundColor="Yellow" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Frame>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Key="PI_N_Template">
|
||||||
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
|
<Grid ColumnSpacing="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
|
||||||
|
<Grid Grid.Column="1" ColumnDefinitions="*,*">
|
||||||
|
<Label Text="I" Grid.Column="0" BackgroundColor="Red" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
<Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Frame>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Key="I_PN_Template">
|
||||||
|
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||||
|
<Grid ColumnSpacing="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Text="{Binding OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="0" />
|
||||||
|
<Grid Grid.Column="1" ColumnDefinitions="*,*">
|
||||||
|
<Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
<Label Text="N" Grid.Column="1" BackgroundColor="Red" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Frame>
|
||||||
|
</DataTemplate>
|
||||||
|
<local:AnswerTypeTemplateSelector x:Key="AnswerTemplateSelector"
|
||||||
|
I_N_Template="{StaticResource I_N_Template}"
|
||||||
|
P_Template="{StaticResource P_Template}"
|
||||||
|
SI_N_Template="{StaticResource SI_N_Template}"
|
||||||
|
I_SN_Template="{StaticResource I_SN_Template}"
|
||||||
|
PI_N_Template="{StaticResource PI_N_Template}"
|
||||||
|
I_PN_Template="{StaticResource I_PN_Template}"/>
|
||||||
|
</ContentPage.Resources>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using WorkFlowCheck.Common.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
|
|
||||||
@@ -44,4 +43,32 @@ public partial class CheckPointEditPage : ContentPage
|
|||||||
await Shell.Current.GoToAsync("//CheckPointsPage");
|
await Shell.Current.GoToAsync("//CheckPointsPage");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public class AnswerTypeTemplateSelector : DataTemplateSelector
|
||||||
|
{
|
||||||
|
public DataTemplate I_N_Template { get; set; }
|
||||||
|
public DataTemplate P_Template { get; set; }
|
||||||
|
public DataTemplate SI_N_Template { get; set; }
|
||||||
|
public DataTemplate I_SN_Template { get; set; }
|
||||||
|
public DataTemplate PI_N_Template { get; set; }
|
||||||
|
public DataTemplate I_PN_Template { get; set; }
|
||||||
|
|
||||||
|
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
|
||||||
|
{
|
||||||
|
if (item is CheckListTemplateRowDTO model)
|
||||||
|
{
|
||||||
|
return model.AnswerType switch
|
||||||
|
{
|
||||||
|
"I-N" => I_N_Template,
|
||||||
|
"P" => P_Template,
|
||||||
|
"SI-N" => SI_N_Template,
|
||||||
|
"I-SN" => I_SN_Template,
|
||||||
|
"PI-N" => PI_N_Template,
|
||||||
|
"I-PN" => I_PN_Template,
|
||||||
|
_ => I_N_Template
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user