We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Bind custom business object to SFKanban card

I am attempting to create a custom Kanban card view to use inside of the SfKanban control. I have it mostly working, except that the binding values do not show correctly. My SfKanban control is set up as follows:

<kanban:SfKanban Grid.Row="1"  
                                 ItemsSource="{Binding CurrentResources}"
                                 Columns="{Binding TacPlanColumns}"
                    <!--CardTemplate="{StaticResource ResourceCard}">-->
                            <controls:ResourceCard Value="{Binding}"/>

The columns are created successfully, and the correct number of cards show up, but Value is not bound in the ResourceCard control. 

The ResourceCard.xaml uses the following:
<Border Background="White" BorderBrush="Black" BorderThickness="2" CornerRadius="4" Margin="2">
        <Grid Background="White" Margin="2">
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="30"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="5"/> <!-- par timer -->
            <TextBlock Grid.Column="0" Grid.Row="0" Margin="1" Text="{Binding ResourceId}" FontWeight="Bold" Style="{DynamicResource TextBlockStyle}"/>
            <TextBlock Grid.Column="0" Grid.Row="1" Margin="1" Text="{Binding AssignedPersons}" FontStyle="Italic" Style="{DynamicResource TextBlockStyle}"/>
            <skia:SKElement x:Name="canvasView" PaintSurface="CanvasView_PaintSurface" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Margin="0"/>
            <Image Grid.Column="1" Grid.Row="0" Source="{Binding StatusImagePath}" Height="30" Width="30"/>
            <Image Grid.Column="1" Grid.Row="1" Source="{Binding InChargeImagePath}" Height="30" Width="30"/>

In the code behind, I have added a DependencyProperty for Value, but it is never set. 

I have looked at previous questions about this on this forum, and they have been provided links to the Getting Started project, which does not do what I need it to do. Is this even possible?

1 Reply

MK Muneesh Kumar G Syncfusion Team January 16, 2019 07:08 AM UTC

Hi Dev, 
Greetings, we have analyzed your query and code snippet and checked the same with our sample. We suspect that you have not implemented OnPropertyChanged method handler for that dependency property. We have tested this handler with property changed, it works fine. Please find the code snippet below.  
public partial class ResourceCard : UserControl 
        public ResourceCard() 
        public object Value 
            get { return (object)GetValue(ValueProperty); } 
            set { SetValue(ValueProperty, value); } 
        // Using a DependencyProperty as the backing store for Value.  This enables animation, styling, binding, etc... 
        public static readonly DependencyProperty ValueProperty = 
            DependencyProperty.Register("Value", typeof(object), typeof(ResourceCard), new PropertyMetadata(null, OnValueChanged)); 
        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
            var value = e.NewValue; 
We have prepared a sample based on your code snippet, please find it in below location.  
If still you face the problem, please revert us by modifying the sample based on your application along with replication procedure. This would be helpful for us to give better solution in this. 
Muneesh Kumar G.   

Live Chat Icon For mobile
Up arrow icon