
foreach (ClienteBE _cliente in this.lstCliente) { tam = _cliente.Nome.Length > tam ? _cliente.Nome.Length : tam; this.cmbCliente.DisplayMemberPath = "Nome"; this.cmbCliente.Items.Add(_cliente); }Hi,
I am working with RadGridView, in MVVM WPF application and I need to validate cell compared to other values in binding collection.
I have a object :
public class MyObject
{
public DateTime DateBegin { get; set;}
public int Value { get; set;}
}
And if I add a new row in my GridView with existing Date I want to show error message in cell.
I thought to use an ValidationRules in my cell, but i am not sure if i can compared to with others values in binding list.
I found some solution, but isn't MVVM compliant :
public void RadGridView1_CellValidating(object sender, GridViewCellValidatingEventArgs e) { bool isValid = true; string validationText = "Validation failed. "; if(cell.column.uniquename == "mydatecolumn") { GridViewCell cell = e.Cell; isValid = ValidateDate((datetime) e.NewValue); if (!isValid) { validationText += "You already used that date, mate."; } }} private static bool ValidateDate(datetime newDate) { // Some linq to see if it's in your collection or not }
Hi All,
I have a datagrid with one of datacolumn contains a combobox.
DataGrid contains a RowDetails template attached to it.
When i add a row into datagrid on click of button or delete a row from datagrid, selection change event of combobox gets called.
RowDetails template also contains a combobox with a selection change event.
When i am trying to click somewhere inside the rowdetailstemplate or trying to use a template scroll bar, combobox selection change event is getting fired.
Please provide the solution how we can avoid selection change event of combobox in above cases.
Please find below piece of code:
<telerik:RadGridView ItemsSource="{Binding Path=Customers}"
IsReadOnly="{Binding IsChecked, Mode=TwoWay, ElementName=IsReadOnlyCheckBox}" RowDetailsVisibilityMode="{Binding RowDetailsTemplateVisibilityMode, Mode=TwoWay}"
SelectionMode="Multiple" AutoGenerateColumns="False" VerticalAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible" MinHeight="100" MaxHeight="350">
<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn Width="30"/>
<telerik:GridViewSelectColumn Width="30"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding SlNo}" Header="S.no" IsReadOnly="True" IsEnabled="False" Width="20" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Product}" Header="Product" IsReadOnly="True" IsEnabled="False" Width="250"/>
<telerik:GridViewDataColumn Header="Customer" Width="Auto">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Path=Customer}" HorizontalAlignment="Left" DisplayMemberPath="RunDesc" SelectedItem="{Binding RunsSelected}" IsEnabled="{Binding IsEnabledRun}" Style="{StaticResource SmallComboBox}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand Command="{Binding Path=LoadCustomersCommand}" PassEventArgsToCommand="False" CommandParameter="{Binding Path=DataContext,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ComboBox}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
<telerik:RadGridView.RowDetailsTemplate >
<DataTemplate>
<Grid Background="{StaticResource MainBackgroundColor}" >
<ComboBox ItemsSource="{Binding Path=Customer}" HorizontalAlignment="Left" DisplayMemberPath="RunDesc" SelectedItem="{Binding RunsSelected}" IsEnabled="{Binding IsEnabledRun}" Style="{StaticResource SmallComboBox}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand Command="{Binding Path=LoadCustomersCommand}" PassEventArgsToCommand="False" CommandParameter="{Binding Path=DataContext,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ComboBox}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</Grid>
</DataTemplate>
</telerik:RadGridView.RowDetailsTemplate>
</telerik:RadGridView>