Estoy intentando utilizar mensaje de micro Caliburn para activar un evento adjunto que he creado:el uso de eventos conectados con Caliburn micro Message.Attach
public static class DataChanging
{
public delegate void DataChangingEventHandler(object sender, DataChangingEventArgs e);
public static readonly RoutedEvent ChangingEvent =
EventManager.RegisterRoutedEvent("Changing",
RoutingStrategy.Bubble,
typeof(DataChangingEventHandler),
typeof(DataChanging));
public static void AddChangingHandler(DependencyObject o, DataChangingEventHandler handler)
{
((UIElement)o).AddHandler(DataChanging.ChangingEvent, handler);
}
public static void RemoveChangingHandler(DependencyObject o, DataChangingEventHandler handler)
{
((UIElement)o).RemoveHandler(DataChanging.ChangingEvent, handler);
}
public static bool GetActivationMode(DependencyObject obj)
{
return (bool)obj.GetValue(ActivationModeProperty);
}
public static void SetActivationMode(DependencyObject obj, bool value)
{
obj.SetValue(ActivationModeProperty, value);
}
public static readonly DependencyProperty ActivationModeProperty =
DependencyProperty.RegisterAttached("ActivationMode",
typeof(bool),
typeof(DataChanging),
new FrameworkPropertyMetadata(false,
HandleActivationModeChanged));
private static void HandleActivationModeChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
{
var dataGrid = target as XamDataGrid;
if (dataGrid == null) // if trying to attach to something else than a datagrid, just ignore
return;
if ((bool)e.NewValue)
{
dataGrid.RecordDeactivating += selector_RecordDeactivating;
}
else
{
dataGrid.RecordDeactivating -= selector_RecordDeactivating;
}
}
static void selector_RecordDeactivating(object sender, RecordDeactivatingEventArgs e)
{
var args = new DataChangingEventArgs(DataChanging.ChangingEvent,sender)
{
Data = ((DataRecord) e.Record).DataItem,
ShouldCancelChange = false
};
(sender as UIElement).RaiseEvent(args);
e.Cancel = args.ShouldCancelChange;
}
}
En el propio XAML añadí la siguiente línea:
cal:Message.Attach="[Helpers:DataChanging.Changing] = [Action SelectedDataChanged($eventArgs)]"
Los ayudantes se refieren al espacio de nombres correcto. También probé otras versiones que fallaron (espacio de nombre completo):
cal:Message.Attach="[clr-namespace:RTF.Client.UI.Helpers.DataChanging.Changing] = [Action SelectedDataChanged($eventArgs)]"
trató de establecer el evento de interacción por mí mismo:
Cuando He intentado añadir un evento normal desencadenar todo funcionaba bien, por lo que no es mi declaración de evento adjunto:
<EventTrigger RoutedEvent="Helpers:DataChanging.Changing">
<EventTrigger.Actions>
<BeginStoryboard x:Name="sb">
<Storyboard x:Name="dsf">
<Storyboard x:Name="myStoryboard">
<BooleanAnimationUsingKeyFrames Storyboard.TargetName="SSS" Storyboard.TargetProperty="IsChecked">
<DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="False" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
¿Qué estoy haciendo? ng aquí? No hay forma de adjuntar un evento adjunto e invocarlo utilizando caliburn micro?
lo probé, pero el mensaje de acción Caliburn sólo es aplicable como la acción de sistema .windows. interactividad. Evento desencadenante y no el normal. para ser sincero, no estoy seguro de cuál es la diferencia entre el 2. No pude iniciar mi evento utilizando el disparador system.windows.interactivity.event. – Clueless