Set bold in ScheduleCellCreated

Hi,

is it possible set bold and other style component in the event written in the object of the ticket?

Best regards
Gian Piero Truccolo

3 Replies 1 reply marked as answer

SS Sridevi Sivakumar Syncfusion Team June 21, 2021 07:04 AM UTC

Hi Gian Piero Truccolo, 
Query: is it possible set bold and other style component in the event written in the object of the ticket? 
We  have checked your reported query and we can customize the schedule style as per below code snippet,  
In App.xaml.cs 
  
<Style x:Key="ScheduleCellStyle" 
       TargetType="ContentControl"> 
    <Setter Property="FontWeight" 
            Value="Bold" /> 
    <Setter Property="Foreground" 
            Value="Black" /> 
</Style> 
  
In MainWindow.cs 
  
private void Gantt_ScheduleCellCreated(object sender, ScheduleCellCreatedEventArgs args) 
{ 
    if (args.CurrentCell.CellTimeUnit == TimeUnit.Days && args.CurrentCell.CellDate.DayOfWeek == DayOfWeek.Sunday) 
    { 
        args.CurrentCell.Style = Application.Current.Resources["ScheduleCellStyle"as Style; 
    } 
    else 
    { 
        args.CurrentCell.Style = null; 
    } 
} 
  
Output: 
 
  
Regards,
Sridevi S.
 



GI Gian June 21, 2021 03:08 PM UTC

Hi,

 i have looked also for Text decoration porperty in  order to set Undeline but i don not  find it.


Is it possible to set?


Best regards

Gian Piero Truccolo



SS Sridevi Sivakumar Syncfusion Team June 22, 2021 03:06 PM UTC

Hi Gian Piero Truccolo,

Query: I have looked also for Text decoration property in order to set Underline but I do not find itIs it possible to set it?
Yes, we can set the Underline to the schedule cell text by customizing the Schedule cell template. The customized template sets the schedule cell in the ScheduleCellCreated event as per the below code snippet 
[App.XAML] 
    <Application.Resources> 
        <Style x:Key="scheduleStyle" TargetType="{x:Type schedule:GanttScheduleCell}"> 
            <Setter Property="Template"> 
                <Setter.Value> 
                    <ControlTemplate TargetType="{x:Type schedule:GanttScheduleCell}"> 
                        <Border  BorderThickness="0,0,1,1" 
                            BorderBrush="Black" > 
                            <TextBlock Name="TextBlock1"  Margin="10,10,0,0" VerticalAlignment="Center"   
    HorizontalAlignment="Center"  Text="{TemplateBinding Content}" 
    FontSize="8" FontFamily="Verdana"  Padding="0,0,0,3"  TextDecorations="Underline"> 
                                   <ToolTipService.ToolTip> 
                                        <ToolTip Content="{TemplateBinding CellToolTip}"/> 
                                    </ToolTipService.ToolTip> 
                            </TextBlock> 
                        </Border> 
                    </ControlTemplate> 
                </Setter.Value> 
            </Setter> 
        </Style> 
 
    </Application.Resources> 

[MainWindow.cs] 
        private void Gantt_ScheduleCellCreated(object sender, ScheduleCellCreatedEventArgs args) 
        { 
            if (args.CurrentCell.CellTimeUnit == TimeUnit.Days && args.CurrentCell.CellDate.DayOfWeek == DayOfWeek.Monday) 
            { 
             args.CurrentCell.Style = Application.Current.Resources["scheduleStyle"] as Style; 
            } 
        } 
  
Screenshot:
 
Please have a sample from the below link 
Sample link:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/GanttSample596667281

Let us know if you need any further assistance.


Regards,
Sridevi S. 
 


Marked as answer
Loader.
Up arrow icon