Hello,
I have a CustomKanbanModel created within Kanban. The Opened state causes the color of a button in the CardTemplate to change. The color of the button does not change when Opened is set to false or true at run time. However, if I drag and drop the card, the color of the card changes.
public class CustomKanbanModel : KanbanModel
{
private int _boxId;
private bool? _opened = null;
public int BoxId
{
get => _boxId;
set
{
_boxId = value;
NotifyPropertyChanged("BoxId");
}
}
public bool? Opened
{
get => _opened;
set
{
_opened = value;
NotifyPropertyChanged("Opened");
}
}
public event PropertyChangedEventHandler PropertyChanged;
internal void NotifyPropertyChanged(string propertyName = "")
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
<syncfusion:SfKanban Name="CustomKanban"
Columns="{Binding Columns}"
ItemsSource="{Binding Boxes}"
ColumnWidth="221"
Grid.Row="1">
<syncfusion:SfKanban.CardTemplate>
<DataTemplate>
<Grid>
<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="0"
Grid.Row="1"
Height="28"
Width="50"
Command="{Binding DataContext.OpenBoxCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding}">
<materialDesign:PackIcon Kind="Lock"
Foreground="White" />
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding Opened}"
Value="True">
<Setter Property="Background"
Value="Green" />
</DataTrigger>
<DataTrigger Binding="{Binding Opened}"
Value="False">
<Setter Property="Background"
Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding Opened}"
Value="{x:Null}">
<Setter Property="Background"
Value="Orange" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Border Height="4"
Grid.Row="2">
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding Opened}"
Value="True">
<Setter Property="Background"
Value="Green" />
</DataTrigger>
<DataTrigger Binding="{Binding Opened}"
Value="False">
<Setter Property="Background"
Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding Opened}"
Value="{x:Null}">
<Setter Property="Background"
Value="Orange" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
</Grid>
</DataTemplate>
</syncfusion:SfKanban.CardTemplate>
</syncfusion:SfKanban>
Opened definitely changes in the background. When I apply it to a button that is not in sfkanban, it works fine, but it is not reflected in sfkanban.
For testing purposes, I changed the default ID from KanbanModel. ID is changing. Changes within the CustomKanbanModel do not seem to be reflected.
When I give INotifyPropertyChanged as inheritance to CustomKanbanModel, Opened state works fine. This time, the default ID will not work.
Hi Özgür,
Thank you for contacting us. We've investigated the issue based on the details provided, and we couldn't replicate it on our end. The sample we created using the code snippet you shared worked as expected, allowing us to change the button's color when `Opened` is set to true or false at runtime.
We have attached the output video and the tested sample for your review. Please check with our sample and let us know if you are still facing the same issue. If the problem persists, could you please modify our sample to match your scenario, ensuring that the issue reproduces? Alternatively, if modifying our sample is not feasible, please provide us with your sample code where you encountered the issue. Additionally, a video demonstrating the problem would be helpful for further investigation.
Regards,
Vidyalakshmi M.