This is a migrated thread and some comments may be shown as answers.

InputBindings no longer work when RowStyleSelector condition changes row style

3 Answers 298 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CyberBotX
Top achievements
Rank 2
Veteran
CyberBotX asked on 10 Nov 2020, 04:10 PM

I've got a RadGridView that contains a RowStyleSelector and an InputBindings section. The RowStyleSelector has 2 conditions, one checking if a value is true and one checking if a value is false. In the false case, the only thing being done is setting the style to be based on the existing GridViewRowStyle with no changes. In the true case, the same happens but the background color is changed. When the false case is used, my InputBindings work fine. Once the true case is used, though, my InputBindings stop working. (Related, I also use behaviors via Microsoft.Xaml.Behaviors.Wpf, with one of them being to bind a command to the MouseDoubleClick event, and that event also stops firing when the above happens with the InputBindings.)

I had set a breakpoint in my code to see if it the command was getting hit and it would only be hit when the false case happened above.

In the below example, assume that Items contains a Cond boolean property:

<telerik:RadGridView GroupRenderMode="Flat" IsReadOnly="True" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Items, Mode=OneWay}" RowIndicatorVisibility="Collapsed" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ShowGroupPanel="False">
    <telerik:RadGridView.RowStyleSelector>
        <telerik:ConditionalStyleSelector>
            <telerik:StyleRule Condition="Cond">
                <Style BasedOn="{StaticResource GridViewRowStyle}" TargetType="{x:Type telerik:GridViewRow}">
                    <Setter Property="Background" Value="Orange"/>
                </Style>
            </telerik:StyleRule>
            <telerik:StyleRule Condition="!Cond">
                <Style BasedOn="{StaticResource GridViewRowStyle}" TargetType="{x:Type telerik:GridViewRow}"/>
            </telerik:StyleRule>
        </telerik:ConditionalStyleSelector>
    </telerik:RadGridView.RowStyleSelector>
    <telerik:RadGridView.InputBindings>
        <KeyBinding Key="Enter" Command="{Binding SelectItemCommand, Mode=OneTime}" />
        <KeyBinding Key="Tab" Command="{Binding SelectItemCommand, Mode=OneTime}" />
    </telerik:RadGridView.InputBindings>
</telerik:RadGridView>

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 13 Nov 2020, 09:43 AM

Hello,

Thank you for the provided code snippet and detailed explanation.

I want to start by clarifying that "!Cond" is not a valid syntax for the Condition property and you need to use "Not Cond" instead. You can test this by also setting a Background for the False condition style and check if it's being applied.

With this said, however, the InputBindings work correctly in both cases in the small sample project I've set up. Can you please have a look and let me know how this setup differs from the one in your application? 

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
CyberBotX
Top achievements
Rank 2
Veteran
answered on 13 Nov 2020, 07:56 PM

Well, I'm honestly at a loss here. I have tried to edit your example to include some things I have in my actual project:

  • Using .NET Core 3.1 instead of .NET Framework 4.5
  • Using PostSharp for INotifyPropertyChanged support as well as its Command aspect
  • Having the RadGridView in a UserControl
  • Something I didn't mention in my original post because I didn't think it would matter (and it doesn't), which was that I also have a cell style selector set on some of my columns
  • Trying to include Microsoft.Xaml.Behaviors.Wpf and using a behavior to bind a command to the MouseDoubleClick event
  • Included all the other attributes on RadGridView that I had in my example

None of these changes made a difference, your example still functions while my actual project does not. So I've made your example as close to my actual project as possible and I have no idea what I've done differently in my actual project that makes the bindings (and the MouseDoubleClick event behavior) fail for me when the condition for the row style is true.

Unfortunately I cannot post my actual project.

0
Dilyan Traykov
Telerik team
answered on 16 Nov 2020, 02:38 PM

Hello,

This is indeed strange and unfortunate.

I'm afraid that without being able to replicate this issue at my end, it is hard for me to suggest a possible cause for it. My only suggestion would be to try and isolate the issue in your original project and send it in a new support ticket. As per our end user license agreement, we guarantee full confidentiality when handling your case.

Please let me know whether this would be possible for you.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
CyberBotX
Top achievements
Rank 2
Veteran
Answers by
Dilyan Traykov
Telerik team
CyberBotX
Top achievements
Rank 2
Veteran
Share this question
or