I have a Silverlight UserControl with a Telerik RadGridView control and a handful of button controls. The problem is that when I edit a cell in the grid view and then click any of the buttons the button command does not execute until; the button is selected a second time. The first press seems to remove the focus from the RadGridView and second succeeds in firing the bound command. Obviously, this makes for a terrible user interface. Does anyone know what might be going on here?
With the exception of the UI behavior everything else works fine.
Simplified XAML:
<StackPanel Orientation="Horizontal">
<Button Content="Save" Command="{Binding SaveCommand}" />
<Button Content="Close" Command="{Binding CloseCommand}" />
</StackPanel>
<telerik:RadGridView ItemsSource="{Binding StockItems,Mode=TwoWay}"
AutoGenerateColumns="False"
IsFilteringAllowed="False"
ShowGroupPanel="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding LabelGroup,Mode=TwoWay}"
Header="Label Group" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Message,Mode=TwoWay}"
Header="Message" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Thanks in advance,
Jim
The problem is already fixed - you can check this thread for more info:
http://www.telerik.com/community/forums/silverlight/gridview/why-do-we-need-to-click-twice-on-a-button-within-a-radgridview.aspx
Related
I have tried like this :
<telerik:GridViewDataColumn x:Name="ReferenceCols"
UniqueName="Reference" SortingState="Ascending" DataMemberBinding="{Binding Ref, Mode=OneWay}"
DisplayIndex="0" MaxWidth="197"
Header="title"
Style="{StaticResource ReadOnlySortableFilterableGridTextColumn}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<telerik:RadRadioButton Content="{Binding Reference}" CornerRadius="20" Width="30"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
but it is not working as radio button for telerik is different and it is showing content inside the button.Please help me on this
The Telerik RadRadioButton control renders as a button and not the older style shown in your first screenshot.
In this case I would recommend using the standard WPF RadioButton control.
Hi I have a telerik RadGridView bound up to an observable collection via MVVM and the SelectedItem property of the grid is also bound to a property from within the model as well. There is then a button column that is bound to open the selected item to see more details of the selected item. The code for this is below.
<telerik:RadGridView Name="RadGridView"
Height="900"
AutoGenerateColumns="False"
CanUserSortColumns="True"
IsReadOnly="True"
ItemsSource="{Binding Model.Items}"
SelectedItem="{Binding Model.SelectedItem,Mode=TwoWay}"
Width="990">
<telerik:RadGridView.Columns>
<telerik:GridViewColumn Header="Open Item" >
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content="Open"
Command="{Binding Path=DataContext.OpenItemBySelectedItemCommand,
RelativeSource= {RelativeSource FindAncestor,
AncestorType={x:Type telerik:RadGridView}}}">
</Button>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding DateScanned}" Header="Date Scanned" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Amount}" Header="Amount" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="Description" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding IsRefund}" Header="Is Refund" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Now this code works fine whenever I click into the row then click the button, however if I just click the button of the row without clicking into the row first the SelectedItem property is not set and so the command does not function as expected.
I thought when clicking the button of a row it would auto select that row but apparently not. Does anyone know how I can get it to set the SelectedItem property whenever I only click on the button within a specific row without having to click on the row before clicking the button?
You could pass a reference to the underlying data object as a command parameter to the command:
<Button Content="Open"
Command="{Binding Path=DataContext.OpenItemBySelectedItemCommand, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}}}"
CommandParameter="{Binding}">
</Button>
For the row to actually become selected when you click on the Button, you will have to write some code that actually selects it. You could do this by handling the Button's Click event like this:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
RadGridView.SelectedItem = button.DataContext;
}
<Button Content="Open"
Click="Button_Click_1"
Command="{Binding Path=DataContext.OpenItemBySelectedItemCommand,
RelativeSource= {RelativeSource FindAncestor,
AncestorType={x:Type telerik:RadGridView}}}">
</Button>
This does not break the MVVM pattern since selecting a row in the view is pure view functionality.
I am working with five text boxes and two comboboxes in xaml.
When I click on Tab key it comes from top to bottom(textboxes to comboboxes),
when I click on shift + Tab it doesn't move from combobox to textbox.
My Combobox is
<TextBlock Text="Select" Style="{StaticResource WaterMarkTextBlockStyle}" Visibility="{Binding ElementName=ComboCOM, Path=Text.IsEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<ComboBox x:Name="ComboCOM" ItemsSource="{Binding COM.COM}" SelectedItem="{Binding TestResultsEntity.CountryOfOrigin,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay,ValidatesOnDataErrors=True,ValidatesOnExceptions=True,NotifyOnValidationError=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplateSilverlightStyle}" IsReadOnly="True" IsHitTestVisible="{Binding TestResultsIsHitTestVisible}" Margin="0" Background="Transparent" >
<i:Interaction.Triggers>
<UC:EventTriggerHandler EventName="Loaded">
<i:InvokeCommandAction Command="{Binding GetCOMComboName}" CommandParameter="{Binding ElementName=ComboCOM}"/>
</UC:EventTriggerHandler>
</i:Interaction.Triggers>
</ComboBox>
Could you please provide me the solution,thanks in advance.
Also this is an old post, I wanted to share my experience.
I came across the same problem with TextBoxes and CheckBoxes inside a Window. Tab worked for jumping to the next Control, Shift+Tab did not work.
The solution was to set TabIndex property on all controls in the Window/UserControl.
Is there a way to fix the known bug of Selection Change Event, selecting does not work if the same item is tapped again.
to give further background, my scenario is that I have four items in my pivot page and when I click one of those items i will be navigated to another page. Now my dilemma is that when i select the same items again, navigation does not work or nothing happens.
Please let me know your suggested fix, thanks much in advance.
<ListBox x:Name="lbviewlist" ItemsSource="{Binding items}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="selectionchanged">
<Command:EventToCommand Command ="{Binding ItemListCommand }" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock TextWrapping="Wrap" Text="{Binding itemName}" FontSize="30" Margin="10,0,0,0" Style="{StaticResource PhoneTextTitle2Style}" Foreground="CadetBlue"/>
<TextBlock TextWrapping="Wrap" Text="{Binding itemDescription}" FontSize="20" Margin="15,5,0,10"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
A good alternative approach is to include all of the content in each item inside a button, which is styled to be invisible so that you never see it, but it covers the surface of the item it encapsulates. If you're using MVVM you can bind the same command property to each of your 'buttons' and bind the DataContext of the button (your data item) to the command parameter. Then whenever you click an item you'll get the command firing every time.
You might want to change your items control to something simple so that the selection changed events dont get in the way.
I'm having a problem with the DevExpress wpf grid binding when using the ComboBoxEditSettings. Below is the grid. I'm binding the "Associated Well Types" column to a property on my ViewModel. However, when I select some items from the combo box and then click "Ok", I see the selected items in the cell, but they don't bind back to my ViewModel. So, do I need to do something with the "Ok" button's click event? Is there
something in the binding that I'm not setting up properly? All of the above?
Thanks in advance for your help.
<ctrls:GridControl Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Margin="5"
dx:ThemeManager.ThemeName="Office2007Blue"
x:Name="gridControlForms" VerticalAlignment="Stretch"
ShowLoadingPanel="{Binding TaxFormsIsBusy}"
ItemsSource="{Binding TaxFormList}" >
<ctrls:GridControl.Columns>
<dxg:GridColumn FieldName="DisplayName" Header="Form Name" VisibleIndex="1" AllowMoving="False" />
<dxg:GridColumn ReadOnly="True" FieldName="PrintSequence" Header="Print Sequence" VisibleIndex="2" AllowMoving="False" />
<dxg:GridColumn Header="Associated Well Types" FieldName="SelectedWellTypes" VisibleIndex="3" AllowMoving="False" AllowBestFit="True" Width="300" >
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding WellTypes}" DisplayMember="WellType" ValueMember="RenditionStateFormWellTypeId" IsTextEditable="False" >
<dxe:ComboBoxEditSettings.StyleSettings>
<dxe:CheckedComboBoxStyleSettings />
</dxe:ComboBoxEditSettings.StyleSettings>
</dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</ctrls:GridControl.Columns>
<ctrls:GridControl.View>
<dxg:TableView ShowGroupPanel="False" BestFitArea="All" AllowSorting="False"
FocusedRow="{Binding SelectedTaxForm, Mode=TwoWay}" AllowColumnFiltering="False" />
</ctrls:GridControl.View>
I discovered the problem: the grid was throwing an "Object must implement IConvertible" error. Once I discovered that, I changed SelectedWellTypes from an int to a IEnumberable of type object and did the appropriate conversions in the viewmodel. This allowed the binding to occur.