Ticket T434090
Visible to All Users

WPF CheckEdit Events Binding

created 8 years ago

I am trying to bind a command to the checked event of the CheckEdit Control.   What I need to do is when All is checked  values of the individual months in model to checked.  Here is the XAML

XAML
<dxlc:LayoutGroup Orientation="Vertical" Header="Reporting Months" View="GroupBox" Background="White" > <dxlc:LayoutGroup Orientation="Horizontal"> <dxlc:LayoutItem IsRequired="True" Label="All" LabelPosition="Left" > <dxe:CheckEdit IsChecked="{Binding Parameter.RptAll}" /> </dxlc:LayoutItem> </dxlc:LayoutGroup> <dxlc:LayoutGroup Orientation="Horizontal"> <dxlc:LayoutItem IsRequired="True" Label="January" LabelPosition="Left" > <dxe:CheckEdit IsChecked="{Binding Parameter.RptJan}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="February" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptFeb}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="March" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptMar}"/> </dxlc:LayoutItem> </dxlc:LayoutGroup> <dxlc:LayoutGroup Orientation="Horizontal"> <dxlc:LayoutItem IsRequired="True" Label="April" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptApr}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="May" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptMay}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="June" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptJun}"/> </dxlc:LayoutItem> </dxlc:LayoutGroup> <dxlc:LayoutGroup Orientation="Horizontal"> <dxlc:LayoutItem IsRequired="True" Label="July" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptJul}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="August" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptAug}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="September" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptSep}"/> </dxlc:LayoutItem> </dxlc:LayoutGroup> <dxlc:LayoutGroup Orientation="Horizontal"> <dxlc:LayoutItem IsRequired="True" Label="October" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptOct}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="November" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptNov}"/> </dxlc:LayoutItem> <dxlc:LayoutItem IsRequired="True" Label="December" LabelPosition="Left"> <dxe:CheckEdit IsChecked="{Binding Parameter.RptDec}"/> </dxlc:LayoutItem> </dxlc:LayoutGroup> </dxlc:LayoutGroup>

I tried binding it to a command using

XAML
Checked="{Binding AllMonthsCheckedCommand}"

But when the window loads I get the following error.

{"'Provide value on 'System.Windows.Data.Binding' threw an exception.' Line number '137' and line position '44'."}

The line and position reference the Checked event in the XAML.

Basically what I am trying to do here and in other places is if a checkbox is checked or unchecked make changes to the model that are then reflected in what the user sees.  For example another thing I am trying to do is if a user checks a box change the background color of a panel.

Any suggestions or pointers to examples / tutorials would be appreciated.

Thanks.

Tom

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hi Tom,

While Checked is an event and cannot be bound to a command directly (that is why the exception occurs), you can use EventToCommand to execute a command when this event is raised. Please try it on your side.

In the meantime, you can provide a similar layout and functionality using our ListBoxEdit. It automatically displays check boxes and the Select All item when the CheckedListBoxEditStyleSettings object is applied. Please try this approach too - perhaps, it will be convenient in your scenario.

    Show previous comments (1)
    Andrey Marten (DevExpress Support) 8 years ago

      Hello Thomas,

      I see that the Command property in your EventToCommand is set to the "CheckedCommand" string. The value of the String type cannot be used as a value of the ICommand type and as a result you get the corresponding markup exception. So, change the implementation as follows:

      XAML
      <dxe:CheckEdit x:Name="Test" Grid.Row="1">Check Box <dxmvvm:Interaction.Behaviors> <dxmvvm:EventToCommand EventName="Checked" Command="{Binding CheckedCommand}"></dxmvvm:EventToCommand> </dxmvvm:Interaction.Behaviors> </dxe:CheckEdit>

      Please try this and let me know your results.

      Thanks,
      Andrey

        That worked.  My bad for not catching it.  Sometimes I get going to quick and forget that I have to bind the method.

        Many thanks for your help.

        Tom

        Andrey Marten (DevExpress Support) 8 years ago

          It's OK, Tom. I'm happy to hear that the issue is now resolved.
          Feel free to contact us if you have other questions.
          Andrey

          Other Answers

          created 6 years ago

          This helped me solve the check box issue in 3rd point:

          1. User checks the check box and select "No" from warning.
          2. Check box is not checked
          3. Event is fired once again when the user clicks the mouse on the grid anywhere or any other column.
            Problem:
            https://www.devexpress.com/Support/Center/Question/Details/T710994/checked-event-to-command-for-check-edit-column

          Solution:
          https://www.devexpress.com/Support/Center/Question/Details/T610301/gridcontrol-with-checkedit-and-inplacebaseedit-in-the-same-column-won-t-update-the

          Thanks.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.