or
telerik:RadComboBox x:Name="comboCounties" Grid.Row="4" Grid.Column="1" MinWidth="200" IsEditable="True" IsReadOnly="True" StaysOpenOnEdit="True" EmptyText="Please select a county" SelectedIndex="-1" DisplayMemberPath="County" SelectedValuePath="ID" Margin="5" Style="{StaticResource ComboBoxErrorToolTip}"> <telerik:RadComboBox.SelectedValue> <Binding Path="CountyID" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <DataErrorValidationRule></DataErrorValidationRule> </Binding.ValidationRules> </Binding> </telerik:RadComboBox.SelectedValue> </telerik:RadComboBox>private void GetErrors(StringBuilder sb, DependencyObject obj){ foreach (object child in LogicalTreeHelper.GetChildren(obj)) { if (child is TextBox) { TextBox element = child as TextBox; if (element == null) continue; if (Validation.GetHasError(element)) { sb.Append(element.Text + "Missing detail:\r\n"); foreach (ValidationError error in Validation.GetErrors(element)) { sb.Append(error.ErrorContent.ToString()); sb.Append("\r\r"); } } //Check the children of this object for errors GetErrors(sb, element); } if (child is RadComboBox) { RadComboBox element = child as RadComboBox; if (element == null) continue; if (Validation.GetHasError(element)) { sb.Append("Missing detail:\r\n"); foreach (ValidationError error in Validation.GetErrors(element)) { sb.Append(error.ErrorContent.ToString()); sb.Append("\r\r"); } } //Check the children of this object for errors GetErrors(sb, element); } }}//DataErrorValidationRulepublic string this[string propertyName]{ get { if (propertyName == "Address1") { if (string.IsNullOrEmpty(Address1)) { return "Line 1 is required."; } } if (propertyName == "Postcode") { if (string.IsNullOrEmpty(Postcode)) { return "Postcode is required."; } } if (propertyName == "CountyID") { if (CountyID <= 0) { return "County is required."; } } return null; }}//WPF Doesn't use this propertypublic string Error{ get { return null; }}Q1 2012
I have a RadGridView that I am binding to a DataTable. The DataTable is dynamically generated in code. In the first column of the DataTable there is an object. I have an event attached to the RowLoaded event. In the RowLoaded event I want to set the template of the first cell to a Resource Template. This is the code I am using but the cell is always empty.
XAML Template
<ControlTemplate x:Key="FluidEditorTemplate"> <shared:PopupButton PopupHorizontalOffset="0" HorizontalContentAlignment="Left" BorderThickness="0" BorderBrush="Transparent" PopupContent="{Binding}" Foreground="Black" FontWeight="Bold" VerticalContentAlignment="Center" Margin="0,0,10,0" Background="Transparent" IsRounded="True" Grid.Column="1" Grid.Row="1" DisplayMode="Merged" > <shared:PopupButton.PopupContentTemplate> <DataTemplate> <StackPanel Background="DarkGray" > <Button ToolTip="Cancel" Tag="{Binding}" Style="{DynamicResource GreenGlassButtonStyle}" Margin="2" Height="24" Width="110" Foreground="White" Content="Cancel" HorizontalAlignment="Right" /> <Button ToolTip="Modify" Tag="{Binding}" Style="{DynamicResource RedGlassButtonStyle}" Margin="2" Height="24" Width="110" Foreground="White" Content="Modify" HorizontalAlignment="Right" /> <Button ToolTip="Stop" Tag="{Binding}" Style="{DynamicResource RedGlassButtonStyle}" Margin="2" Height="24" Width="110" Foreground="White" Content="Stop" HorizontalAlignment="Right" /> </StackPanel> </DataTemplate> </shared:PopupButton.PopupContentTemplate> </shared:PopupButton> </ControlTemplate>XAML GridView
<telerik:RadGridView RowLoaded="FluidsGridRowLoaded"Grid.Row="1" AutoGenerateColumns="True" ItemsSource="{Binding FluidsDataSource}" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" />Code
private void FluidsGridRowLoaded(object sender, RowLoadedEventArgs e){ if (!DesignerProperties.GetIsInDesignMode(this)) { if (e.Row.Cells.Count > 0) e.Row.Cells[0].Template = Application.Current.Resources["FluidEditorTemplate"] as ControlTemplate; }}
Thanks,
Billy Jacobs
<telerik:RadMaskedTextInput Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Row="0" Grid.Column="1" Name="KundenAns_txt" Value="{Binding Anschrift}" telerik:StyleManager.Theme="Summer"TextMode="PlainText" VerticalContentAlignment="Top" SelectionOnFocus="SelectAll" />public class MyRecord
{ public string MyField { get; set; } }//...public class MyWidget : UserControl{ public class MyRecord { public string MyField { get; set; } } public ObservableCollection<MyRecord> _items = new ObservableCollection<MyRecord>(); public MyWidget() { InitializeComponent(); this.myRadGridView.ItemsSource = this._items; }}