FlowListПросмотреть одну отдельную метку с FlowColumnCount = "1" - PullRequest
0 голосов
/ 15 февраля 2020

После использования FlowListView я получил следующий результат:

enter image description here

Но аварийная ситуация должна быть другого цвета с другим событием щелчка и размером FlowColumnCount = "1"

это следующий код:

<?xml version="1.0" encoding="utf-8" ?>

            <flv:FlowListView.FlowColumnTemplate>
                <DataTemplate>
                    <Frame BackgroundColor="Purple" Margin="5">
                        <Label HorizontalOptions="Fill" 
                        VerticalOptions="Fill" 
                        TextColor="White"
                        XAlign="Center"
                        YAlign="Center" 
                        Text="{Binding Text}"/>
                    </Frame>
                </DataTemplate>
            </flv:FlowListView.FlowColumnTemplate>
        </flv:FlowListView>
    </StackLayout>
</ContentPage.Content>

Это хранилище MockDataStore:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DLToolkit.Forms.Controls;
using EscapeHaarlem.Models;

namespace EscapeHaarlem.Services
{
public class MockDataStore : IDataStore<Item>
{
    List<Item> items;

    public MockDataStore()
    {
        FlowListView.Init();
        items = new List<Item>();
        //this.items.Add(new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 1", Description = "This is an item description." });
        //this.items.Add(new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 2", Description = "This is an item description." });

        var mockItems = new List<Item>
        {
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 1", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 2", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 3", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 4", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 5", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 6", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 7", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 8", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 9", Description="This is an item description." },
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 10", Description="This is an item description."},
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 11", Description="This is an item description."},
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 12", Description="This is an item description."},
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 13", Description="This is an item description."},
            new Item { Id = Guid.NewGuid().ToString(), Text = "Hint 14", Description="This is an item description."},
            new Item { Id = Guid.NewGuid().ToString(), Text = "Emergency", Description="This is an item description."},
        };

        foreach (var item in mockItems)
        {
            items.Add(item);
        }
    }

    public async Task<bool> AddItemAsync(Item item)
    {
        items.Add(item);

        return await Task.FromResult(true);
    }

    public async Task<bool> UpdateItemAsync(Item item)
    {
        var oldItem = items.Where((Item arg) => arg.Id == item.Id).FirstOrDefault();
        items.Remove(oldItem);
        items.Add(item);

        return await Task.FromResult(true);
    }

    public async Task<bool> DeleteItemAsync(string id)
    {
        var oldItem = items.Where((Item arg) => arg.Id == id).FirstOrDefault();
        items.Remove(oldItem);

        return await Task.FromResult(true);
    }

    public async Task<Item> GetItemAsync(string id)
    {
        return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
    }

    public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
    {
        return await Task.FromResult(items);
    }
}

}

Как мне добиться, чтобы аварийная кнопка имела другой цвет и размер клика?

Заранее спасибо

Ответы [ 2 ]

0 голосов
/ 17 февраля 2020

Вы имеете в виду, что хотите выделить Emergency отдельный столбец и иметь отдельное событие щелчка, верно?

Если да, вы можете отобразить его с помощью ListView.Footer, затем вы можете определить его цвет, отдельно щелкнуть событие ,, например:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:d="http://xamarin.com/schemas/2014/forms/design"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         mc:Ignorable="d"
         xmlns:flv="clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView"
         x:Class="App18.FlowListPage">
<ContentPage.Content>
    <StackLayout>
        <flv:FlowListView FlowColumnCount="2"   
            SeparatorVisibility="Default"   
            HasUnevenRows="True"  
            FlowItemTappedCommand="{Binding ItemTappedCommand}"   
            FlowItemsSource="{Binding Items}">

            <flv:FlowListView.FlowColumnTemplate>
                <DataTemplate>
                    <Frame BackgroundColor="Purple"  
            Margin="5">
                        <Label HorizontalOptions="Fill"   
                VerticalOptions="Fill"   
                TextColor="White"  
                XAlign="Center"  
                YAlign="Center"   
                Text="{Binding Text}"/>
                    </Frame>
                </DataTemplate>
            </flv:FlowListView.FlowColumnTemplate>
            <flv:FlowListView.Footer>

                <StackLayout>
                    <Button Text="Emergency" BackgroundColor="Accent" Clicked="Button_Clicked"></Button>
                </StackLayout>

            </flv:FlowListView.Footer>
        </flv:FlowListView>
    </StackLayout>
</ContentPage.Content>

0 голосов
/ 15 февраля 2020

Вам необходимо использовать триггеры свойств как , видимый в документах

псевдокод:

    <Label HorizontalOptions="Fill" 
                            VerticalOptions="Fill" 
                            TextColor="White"
                            XAlign="Center"
                            YAlign="Center" 
                            Text="{Binding Text}">

                     <Label.Triggers>
       <Trigger TargetType="Label" //TargetType sets the element type
                 Property="Text" //Element property that will be watched
                  Value="Emergency">//Value that causes the trigger
            <Setter Property="BackgroundColor" Value="Yellow" />
     //The effects the trigger will have (can be several)
           </Trigger>
     </Label.Triggers>

    </Label>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...