Syncfusion calender OnMonthCellLoaded custom event is passing a null to my command - xaml

Preface: Syncfusion provides a free Calender control called SfCalendar for Xamarin.Forms. This calender has an event called OnMonthCellLoaded. The problem with this event is that its eventargs is type MonthCell which does not inherit from System.EventArgs unfortunately. This is a problem because the eventargs of an event must inherit from System.EvenArgs in order for it to properly used by the Prism EventToCommand behavior.
Objective: I am trying to bind the OnMonthCellLoaded event using prism behaviors in order to set the data context of the MonthCell. I hope this is clear.
Current situation:
I have extended the SfCalendar calender like follow:
public class sfCalendarExtended : Syncfusion.SfCalendar.XForms.SfCalendar
{
public event EventHandler<MonthCellEventArgs> OnMonthCellLoadedExtended;
public sfCalendarExtended()
{
this.OnMonthCellLoaded += SfCalendarExtended_OnMonthCellLoaded;
}
private void SfCalendarExtended_OnMonthCellLoaded(object sender, MonthCell e)
{
if (this.OnMonthCellLoadedExtended != null)
{
if (e != null)
{
Debug.Print(e.Date.ToLongDateString());
var eventArgs = new MonthCellEventArgs() { Value = new MonthCell(e.Date) };
this.OnMonthCellLoadedExtended(this, eventArgs);
}
}
}
}
public class MonthCellEventArgs : System.EventArgs
{
public MonthCell Value { get; set; }
public MonthCellEventArgs()
{
}
}
This is my Xaml
<Controls:sfCalendarExtended x:Name="calendar">
<Syncfusion:SfCalendar.MonthViewSettings>
<Syncfusion:MonthViewSettings DateSelectionColor="#dddddd" CellTemplate="{StaticResource weathertemplate}"/>
</Syncfusion:SfCalendar.MonthViewSettings>
<Syncfusion:SfCalendar.Behaviors>
<prismbehaviors:EventToCommandBehavior EventName="OnMonthCellLoadedExtended" Command="{Binding BindMonthCellToDateCommand}"/>
</Syncfusion:SfCalendar.Behaviors>
</Controls:sfCalendarExtended>
Where controls is the alias for the namespace where the sfCalenderExtended class resides.
Now let's take a look at the Command implementation in my view model:
public DelegateCommand<MonthCellEventArgs> BindMonthCellToDateCommand { get; set; }
public ViewModel()
{
BindMonthCellToDateCommand = new DelegateCommand<MonthCellEventArgs>(
(MonthCellEventArgs obj) =>
{
// more code here
Now everything goes according to plan until I hit MonthCellEventArgs obj with the debugger and obj is always null.
Any help would be highly appreciated.

Alright, so I have emailed Syncfusion about this and they have addressed this issue by changing the args parameter of MonthCellLoaded event handler to inherit from System.EventArgs. More information in their online forum here.
My solution above works if and only if I use Corcav behaviors (see link) instead of Prism behaviors.

We have fixed the issue’s with “System.ArgumentException has been thrown while using EventToCommand behavior in SfCalendar”. As per the implementation Monthcell is moved to EventArgs from View and it is deprecated in OnMonthCellLoaded event and use MonthCellLoadedEventArgs. Please find the Custom assemblies for this fix below.
Custom assemblies: http://www.syncfusion.com/downloads/support/directtrac/217023/ze/Assembly1814496033.zip
Please clear the NuGet cache before replacing the custom assemblies. Please find the link below,
https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache
Assembly Version: 16.3.0.21
Installation Directions:
Replace the files “Syncfusion.SfCalendar.XForms.dll, Syncfusion.SfCalendar.XForms.Android.dll, Syncfusion.SfCalendar.XForms.iOS.dll” under following folders. Before replacing the new assemblies please take backup of old assemblies.
{Syncfusion Installed location} \Essential Studio\16.3.0.21\Xamarin\lib\pcl\Syncfusion.SfCalendar.XForms.dll
{Syncfusion Installed location} \Essential Studio\16.3.0.21\Xamarin\lib\Android\Syncfusion.SfCalendar.XForms.dll
{Syncfusion Installed location}\EssentialStudio\16.3.0.21\Xamarin\lib\Android\Syncfusion.SfCalendar.XForms.Android.dll
{Syncfusion Installed location} \Essential Studio\16.3.0.21\Xamarin\lib\iOS\Syncfusion.SfCalendar.XForms.dll
{Syncfusion Installed location}\EssentialStudio\16.3.0.21\Xamarin\lib\iOS\Syncfusion.SfCalendar.XForms.iOS.dll
Regards,
Vigneshkumar R

Related

Identify which MudExpansionPanel is being expanded

I want to present a list of up to 20 panels within a <MudExpansionPanels> component where the expanded child portion of each <MudExpansionPanel> is expensive to render. I tried the following test code but all instances of <LiveAgentSummary> are rendered as the parent is rendered, just to clarify this rendering of <LiveAgentSummary> happens before any panel is manually expanded.
<MudExpansionPanels>
#foreach (var liveAgent in _liveAgents)
{
<MudExpansionPanel Text=#liveAgent.Name>
<LiveAgentSummary AgentId=#liveAgent.Id />
</MudExpansionPanel>
}
</MudExpansionPanels>
I then looked into delaying the render of each <LiveAgentSummary> through use of a RenderFragment that is dynamically built during the <MudExpansionPanel> IsExpandedChanged event. However the event handler does not indicate which panel is being expanded and hence I do not know which liveAgent.Id param value to pass to <LiveAgentSummary> as I build a RenderFragment.
I think <MudExpansionPanels> is missing support for a bind-ActivePanelId property but hopefully I am overlooking an alternative solution to my delayed rendering objective.
This is the official MudBlazor example that prompted me to look into using a RenderFragment.
Update: A long answer briefly appeared yesterday suggesting that I could query the list of panel components on a built-in property that indicates the expanded state. The poster had gone to the trouble of reading the MudBlazor source code but the answer was then deleted.
I am now wondering how from code in an event handler it is possible to iterate over a component hierarchy declared as mark-up. Applying this to my example markup above, how could event handler code obtain a reference to each <MudExpansionPanel> child within <MudExpansionPanels>.
Can't you make use of the bool from the IsExpandedChanged callback? Something like this:
Index.razor
#page "/"
<MudExpansionPanels>
#foreach (var liveAgent in this.liveAgents)
{
<MudExpansionPanel
Text="#($"{liveAgent.Name} ({liveAgent.Data})")"
IsExpandedChanged="#(e => this.Load(e, liveAgent))">
<LiveAgentSummary Agent="#liveAgent" />
</MudExpansionPanel>
}
</MudExpansionPanels>
#code {
private readonly List<Agent> liveAgents = new()
{
new Agent("1", "Agent Smith"),
new Agent("2", "Agent Brown"),
new Agent("3", "Agent Jones")
};
private void Load(bool expanded, Agent agent)
{
if (expanded)
{
agent.Load();
}
}
}
LiveAgentSummary.razor
<MudText>id: #this.Agent.Id, data: #this.Agent.Data</MudText>
#code {
[Parameter]
public Agent Agent { get; set; } = default!;
}
Agent.cs
public record Agent(string Id, string Name)
{
public string Data { get; set; } = "Not loaded";
public void Load()
{
Console.WriteLine($"Loading agent {this.Id}...");
this.Data = "Loaded!";
}
}

UWP Telerik RadDataGrid not allowing me to end row edit by hitting enter

I am having trouble ending an edit of a row in Telerik's UWP RadDataGrid. Once the data is populated I click on a cell to start an edit. After I finish editing the row I hit enter to finish editing but it remains in edit mode. Clicking a cell in another row ends the edit and the new data is intact but the bound collection does not get updated. Below is a screen shot of the grid I am using:
Here is the XAML code in my page:
<tg:RadDataGrid ColumnDataOperationsMode="Flyout" x:Name="grid" ItemsSource="{x:Bind ViewModel.Source}" UserEditMode="Inline" Grid.ColumnSpan="4" Grid.Row="1"/>
I would really appreciate some help. Thanks so much in advance!
After I finish editing the row I hit enter to finish editing but it remains in edit mode.
I created a 16299 UWP project to test and installed the Telerik.UI.for.UniversalWindowsPlatform(1.0.0.7) package for it. Then, I can reproduce this issue. But if I change my project's target version to "15063", when I hit Enter key, it will commit an edit operation successfully. So, this telerik control might has some issues when it's running in 16299. You could report this issue to their official site of Telerik.
And since the Telerik controls of UWP is open source, you could also check its source code and fix this issue by yourself, then you could compile your custom version by yourself and use it in your project.
I saw the relevant code about this issue maybe in this line code: https://github.com/telerik/UI-For-UWP/blob/master/Controls/Grid/Grid.UWP/View/RadDataGrid.Manipulation.cs#L392 Maybe, you could check it.
Clicking a cell in another row ends the edit and the new data is intact but the bound collection does not get updated.
I have not saw your code, so I didn't know where the issue is. But it worked well on my side. You could check my simple code sample for reference:
<telerikGrid:RadDataGrid x:Name="DataGrid" ItemsSource="{x:Bind ls}" UserEditMode="Inline"></telerikGrid:RadDataGrid>
public sealed partial class MainPage : Page
{
public ObservableCollection<Data> ls { get; set; }
public MainPage()
{
this.InitializeComponent();
ls = new ObservableCollection<Data>() {new Data { Country = "India", Capital = "New Delhi"},
new Data { Country = "South Africa", Capital = "Cape Town"},
new Data { Country = "Nigeria", Capital = "Abuja" },
new Data { Country = "Singapore", Capital = "Singapore" } };
}
}
public class Data:INotifyPropertyChanged
{
private string _Country;
public string Country
{
get { return _Country; }
set
{
_Country = value;
RaisePropertyChange("Country");
}
}
private string _Capital;
public string Capital
{
get { return _Capital; }
set
{
_Capital = value;
RaisePropertyChange("Capital");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChange(string propertyName)
{
if (PropertyChanged!= null)
{
PropertyChanged(this,new PropertyChangedEventArgs(propertyName));
}
}
}

SP2010 Attach Event Receiver to specific list programmatically - runs for all lists

I'm attaching a event receiver to a single list (Web scope). But the ER runs for all lists in the Web. This question says that the feature, the ER is deployed in, have to be Web scope. This is the case.
The Feature is activated programmatically bound to an ER of a list in the TLS.
newProjectWeb.Features.Add(new Guid("57e21870-6285-4e0a-b9a0-067f774492ae"));
Please see my code below. Am I missing an Update or anything?
Thanks for your help in advance.
public void AddEventReceiverToMemberList()
{
try
{
_clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemAdded);
_clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemDeleting);
_clsLists.AddEventReceiverToList(Web, ProjectMemberList.LIST_INTERNAL_NAME, typeof(SCMUProjectMemberList), SPEventReceiverType.ItemUpdated);
Web.Update();
}
catch (Exception)
{
throw;
}
}
public void AddEventReceiverToList(SPWeb web, string listName, Type eventReceiverClass, SPEventReceiverType eventType)
{
SPList list = this.GetListByName(web, listName);
string className = eventReceiverClass.FullName;
string assemblyName = Assembly.GetAssembly(eventReceiverClass).FullName;
list.EventReceivers.Add(eventType, assemblyName, className);
}
If you want to run the event receiver for a single list..
Refer Here
Check the end of the post, Changing the attribute to "ListTemplateId" to "ListURL" in Elements.xml
In the Elements.xml file replace:
<Receivers ListTemplateId="100">
by
<Receivers ListUrl="Lists/Your List Name">

SharePoint 2010 Rename Document on Upload Fails in Explorer View

I'm trying to implement a customization in SharePoint 2010 so that when a document is uploaded to a library, the file name is changed to include the Document ID in the name. (I know that people shouldn't worry about file names as much any more, but we have a lot of legacy files already named and users who like to have local copies).
I was able to implement a custom Event Receiver on the ItemAdded event that renames the file by adding the Document ID before the file name. This works correctly from the web Upload.
The problem is with the Explorer View. When I try to add the file using WebDAV in the Explorer View, I get two copies of the file. It seems that when a file is uploaded via the Web the events that fire are
ItemAdding
ItemAdded
But when I copy/paste a file into Explorer View I see the following events:
ItemAdding
ItemAdded
ItemAdding
ItemAdded
ItemUpdating
ItemUpdated
The result is I have two files with different names (since the Document IDs are different).
I've found a lot of people talking about this issue online (this is the best article I found). Anyone have any other ideas? Would it make more sense to do this in a workflow instead of an event receiver? I could use a scheduled job instead, but that might be confusing to the user if the document name changed a few minutes later.
This is my code that works great when using the Web upload but not when using Explorer View:
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
SPListItem currentItem = properties.ListItem;
if (currentItem["_dlc_DocId"] != null)
{
string docId = currentItem["_dlc_DocId"].ToString();
if (!currentItem["BaseName"].ToString().StartsWith(docId))
{
EventFiringEnabled = false;
currentItem["BaseName"] = docId + currentItem["BaseName"];
currentItem.SystemUpdate();
EventFiringEnabled = true;
}
}
}
catch (Exception ex)
{
//Probably should log an error here
}
base.ItemAdded(properties);
}
I have found that using a Visual Studio workflow allows me the most flexibility to do this. A SharePoint Designer Workflow would be simpler, but would be harder to deploy to different sites and libraries.
After reading some good articles including this and this I have come up with this code which seems to work. It starts a workflow and waits until the document is not in a LockState and then processes the filename.
The workflow looks like this:
And here is the code behind:
namespace ControlledDocuments.RenameWorkflow
{
public sealed partial class RenameWorkflow : SequentialWorkflowActivity
{
public RenameWorkflow()
{
InitializeComponent();
}
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
Boolean continueWaiting = true;
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
CheckFileStatus();
}
private void whileActivity(object sender, ConditionalEventArgs e)
{
e.Result = continueWaiting;
}
private void onWorkflowItemChanged(object sender, ExternalDataEventArgs e)
{
CheckFileStatus();
}
private void CheckFileStatus()
{
if (workflowProperties.Item.File.LockType == SPFile.SPLockType.None)
{
continueWaiting = false;
}
}
private void renameFile(object sender, EventArgs e)
{
try
{
SPListItem currentItem = workflowProperties.Item;
if (currentItem["_dlc_DocId"] != null)
{
string docId = currentItem["_dlc_DocId"].ToString();
if (!currentItem["BaseName"].ToString().StartsWith(docId))
{
currentItem["BaseName"] = docId + currentItem["BaseName"];
currentItem.SystemUpdate();
}
}
}
catch (Exception ex)
{
//Should do something useful here
}
}
}
}
Hope this helps someone else if they have the same problem.
Well i'd go for the workflow workaround... there are 2 options imo:
1) Create a boolean fied in your document library, then create a SPD workflow that fires when the item is added and set that field to "Changed" or something. In the EventReceiver you then check whether that field has been set..
2) Do everything with the SPD workflow - changing the title like in this example should be no problem.

Attach my action to F5/Refresh

i'm writing a plugin for Eclipse and i would like to attach one of my actions to Eclipse F5/Refresh event.
Can anyone help me?
Thanks!
You can attach a IExecutionListener to the ICommandService. You will get notification of all the commands executed. You can look for the command id that you want (in this case org.eclipse.ui.file.refresh) and do your operation
I'm assuming you're writing this for Eclipse Helios (3.6).
In Eclipse help, in the Platform Plug-in Developer Guide -> Programmer's Guide -> Advanced resource concepts -> Refresh providers, there's an extension point.
org.eclipse.core.resources.refreshProviders
Your class has to extend RefreshProvider to use this extension.
According to Prakash G. R., I show the sample code.
Because the initialization code in Activator does not work if we need to use Workbench, therefore I use the startup extension point. The plugin.xml is
<extension
point="org.eclipse.ui.startup">
<startup
class="sampleplugin.MyStartUp">
</startup>
</extension>
Therefore in MyStartUp class we add the ExecutionListener to ICommandService.
The important thing is that the ExecutionEvent in the preExecute method is not able to
extract the selection. This is different from usual ExecutionEvent in Command.
Therefore , the MyStartUp.java is
public class MyStartUp implements IStartup {
#Override
public void earlyStartup() {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService .class);
service.addExecutionListener(
new IExecutionListener() {
...
#Override
public void postExecuteSuccess(String commandId,
Object returnValue) {
// do something post
}
#Override
public void preExecute(String commandId,
final ExecutionEvent event) {
if (org.eclipse.ui.IWorkbenchCommandConstants.FILE_REFRESH.equals(commandId) ) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
ISelection selection = page.getSelection();
// do something using selection
}
}
});
}
}
I use the
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
ISelection selection = page.getSelection();
instead of
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
because the above reason. However, this is due to the Eclipse inner mechanism.
The refresh event uses an old action mechanism and The ExternalActionManager call
preExecute method directly in which the event has no data for selection.
I want the second formula
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
may be available in preExecute method in the future.