Home Forums WPF controls Xceed DataGrid for WPF Can’t Handle Event

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24538 |

    Hello!
    I want to know when my data will be changed and write them back. So, in the xaml code was written

    <Style Target={x:Type xcdg:DataCell}>
    <EventSetter Event=”DataContexChanged” Handler=”cellContentChangedEvent”/>
    </Style>

    Inside the xaml.vb class

    Public Sub cellContentChangedEvent(Byval sender As Object, Byval e As System.Windows.RoutedEventArgs)

    ……..

    End Sub

    After than I have an error:
    System.Windows.FrameworkElement.DataContextChanged=”cellContentChangedEvent” is not valid. “DataContextChanged” must be RoutedEvent registered with a name that ands with the keyword “Event”.

    Where is my mistake? Or is there an another way to do this?
    I understand – the mistake in my xaml code, but can’t – what shoul I do.

    Imported from legacy forums. Posted by Sergey (had 1216 views)

    User (Old forums)
    Member
    Post count: 23064

    In your event handler,
    Public Sub cellContentChangedEvent(Byval sender As Object, Byval e As System.Windows.RoutedEventArgs)
    ByVal has to be DependencyPropertyChangedEventArgs:
    Public Sub cellContentChangedEvent(Byval sender As Object, Byval e As DependencyPropertyChangedEventArgs)

    Imported from legacy forums. Posted by Lena (had 510 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you for reply. I tried to change

    <i>ByVal e As System.Windows.DependencyPropertyChangedEventArgs</i>

    but it does not help. There the same error. I can’t understand what “must be a routed event registered with a name that ends with the keyword “Event”.

    Imported from legacy forums. Posted by Sergey (had 344 views)

    User (Old forums)
    Member
    Post count: 23064

    In MSDN , this explain by following:
    “Event setters invoke the specified event handlers in response to routed events, which apply to all elements that reference the Style rather than requiring you to attach instance handlers to each individual element. Only Style.Setters support EventSetter objects.

    You can only declare event setters for events that are routed events. You can declare event setters for routed events with a direct routing strategy, bubbling events, or tunneling events.

    Instances of the EventSetter class are usually created through Extensible Application Markup Language (XAML), as an object element within a style defined through XAML. An EventSetter might also be instantiated from code.

    Event setters cannot be used in a style that is contained in a theme resource dictionary. This is because a theme resource dictionary at run time is often loose binary XAML (BAML) files, and does not have any scope defined where accompanying code-behind that defines the handlers can exist.

    Handlers attached through event setters are invoked after any class handlers for an event, and also after any instance handlers. As a result, if a class handler or instance handler marks an event handled in its arguments, then the handler declared by an event setter is not invoked, unless the event setter specifically sets HandledEventsToo true.

    Event setters may also come from BasedOn styles. The event setter handlers from the style specified as BasedOn will be invoked after the handlers on the immediate style.

    Note that only Style.Setters supports EventSetter objects. Triggers (TriggerBase and derived classes) do not support EventSetter.

    See ms-help://MS.MSSDK.1033/MS.NETFX30SDK.1033/cpref29/html/T_System_Windows_EventSetter.htm
    Try to do it in C# or Vb code instead.
    Lena

    Imported from legacy forums. Posted by Lena (had 821 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    DataContextChanged is not a RoutedEvent. It therefore cannot be used in EventSetters.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4210 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.