Articles in this section
Category / Section

How to add Kanban task card dynamically in Xamarin.Forms

1 min read

This article explains how to include task dynamically in the Xamarin.Forms Kanban board, as shown in the following.


Kanban board for dynamic task addition

 

 

It has been achieved by adding the new desired Kanban model into the populated view model class property of Kanban ItemsSource as shown in the following code sample.

 

 [XAML]

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <kanban:SfKanban x:Name="kanban" AutoGenerateColumns="False" ItemsSource="{Binding Cards}">
            <kanban:SfKanban.Columns>
                <kanban:KanbanColumn x:Name="openColumn" Title="To Do"  >
                </kanban:KanbanColumn>
                <kanban:KanbanColumn x:Name="progressColumn" Title="In Progress">
                </kanban:KanbanColumn>
                <kanban:KanbanColumn x:Name="codeColumn" Title="Code Review" >
                </kanban:KanbanColumn>
                <kanban:KanbanColumn x:Name="doneColumn" Title="Done"  >
                </kanban:KanbanColumn>
            </kanban:SfKanban.Columns>
        </kanban:SfKanban>
        <Button Text="Add card" Grid.Row="1" x:Name="AddCards" Clicked="AddCards_Clicked"/>
    </Grid>

 

 [C#]

    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
 
            openColumn.Categories = new List<object>() { "Open" };
            progressColumn.Categories = new List<object>() { "In Progress" };
            codeColumn.Categories = new List<object>() { "Code Review" };
            doneColumn.Categories = new List<object>() { "Done" };
       }
 
        private void AddCards_Clicked(object sender, EventArgs e)
        {
            KanbanModel kanbanModel = new KanbanModel()
            {
                ID = 8,
                Title = "iOS - 4576",
                Category = "Open",
                Description = "Show the retrieved data from the server in grid control",
                ColorKey = "Green",
                Tags = new string[] { "Story", "Customer" }
            };
 
            (this.kanban.BindingContext as ViewModel).Cards.Add(kanbanModel);
        }
    }

 

See also


How to add placeholder in Xamarin.Forms Kanban

How to customize the column in Xamarin.Forms Kanban

How to Localize the Xamarin.Forms Kanban

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied