Telerik Forums
UI for WPF Forum
2 answers
695 views
Some weeks ago I implemented a CustomGridViewToggleRowDetailsColumn class.  Basically, my data model has objects called Reads which can have zero or more Alarms associated with them.  I've written code which populates an array in the Read view model object with all of the Alarms that are associated with that particular Read.  The class hides the toggle button for the row details if the item in the row doesn't have any rows in that array.  There's another boolean property on the Read view model object called HasAlarms which is true if the Alarms array isn't empty.

In order to improve performance, I need to rework the data access code so it no longer retrieves all of the Alarms assocated with a Read at the time it retrieves the Reads that match the search criteria.  Instead, I am setting the HasAlarms property to true if there are any Alarms for that Read and leaving the array null. I want the row details toggle button to be hidden if HasAlarms is false (easily done with existing code).  Then, when the user clicks on the toggle button, I want to check to see if the Alarms for that Read were retrieved yet, and if not, go get them.

The problem is that I'm getting an error when the Xaml for the RadGridView is being parsed because it doesn't like something about my code.  The error I'm getting is:

System.Windows.Markup.XamlParseException occurred
  Message='Failed to create a 'Click' from the text 'ExpandAlarms_Click'.' Line number '416' and line position '9'.
  Source=PresentationFramework
  LineNumber=416
  LinePosition=9
  StackTrace:
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at CarSystem.CustomControls.Searcher.InitializeComponent() in d:\ElsagTFS\EOC4\Client UI\CustomControls\Searcher.xaml:line 1
       at CarSystem.CustomControls.Searcher..ctor() in D:\ElsagTFS\EOC4\Client UI\CustomControls\Searcher.xaml.cs:line 431
  InnerException: System.ArgumentException
       Message=Error binding to target method.
       Source=mscorlib
       StackTrace:
            at System.Delegate.CreateDelegate(Type type, Object target, String method, Boolean ignoreCase, Boolean throwOnBindFailure)
            at System.Xaml.Schema.SafeReflectionInvoker.CreateDelegate(Type delegateType, Object target, String methodName)
            at System.Xaml.EventConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
            at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
            at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter`1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
       InnerException:

Here's the code for my class.  Please help me fix this problem.

    class CustomGridViewToggleRowDetailsColumn : GridViewBoundColumnBase {
  
        public static RoutedEvent ClickEvent =
            EventManager.RegisterRoutedEvent( "Click", RoutingStrategy.Bubble, typeof( ToggleRowDetailsColumnRoutedEventHandler ), typeof( CustomGridViewToggleRowDetailsColumn ) );
  
        public GridViewCell Cell { get; set; }
  
        public event RoutedEventHandler Click {
            add { AddHandler( ClickEvent, value ); }
            remove { RemoveHandler( ClickEvent, value ); }
        }
  
        public override object Header {
            get { return null; }
            set { base.Header = value; }
        }
        public GridViewToggleButton ToggleButton { get; set; }
  
        private Binding toggleButtonVisibility;
        public Binding ToggleButtonVisibility {
            get { return toggleButtonVisibility; }
            set { toggleButtonVisibility = value; }
        }
  
        public CustomGridViewToggleRowDetailsColumn() {
            // Set the EditTriggers property to None
            this.EditTriggers = GridViewEditTriggers.None;
        }
  
        public override bool CanFilter() {
            return false;
        }
  
        public override bool CanGroup() {
            return false;
        }
  
        public override bool CanSort() {
            return false;
        }
  
        public override FrameworkElement CreateCellElement( GridViewCell cell, object dataItem ) {
            Cell = cell;
  
            ToggleButton = new GridViewToggleButton { 
                Margin = new System.Windows.Thickness( 3 )
            };
  
            ToggleButton.Click += new RoutedEventHandler( ToggleButton_Click );
  
            if ( this.DataMemberBinding != null ) {
                ToggleButton.SetBinding( GridViewToggleButton.IsCheckedProperty, this.DataMemberBinding );
            }
  
            if ( ToggleButtonVisibility != null ) {
                ToggleButton.SetBinding( GridViewToggleButton.VisibilityProperty, ToggleButtonVisibility );
            }
  
            GridViewRow row = cell.ParentRow as GridViewRow;
  
            row.SetBinding( GridViewRow.DetailsVisibilityProperty, new Binding( "IsChecked" ) { 
                Source = ToggleButton, 
                Converter = new BooleanToVisibilityConverter(), 
                Mode = BindingMode.TwoWay 
            } );
  
            return ToggleButton;
        }
  
        void ToggleButton_Click( object sender, RoutedEventArgs e ) {
            RoutedEventArgs newEventArgs = new ToggleRowDetailsColumnRoutedEventArgs( ClickEvent, Cell );
            RaiseEvent( newEventArgs );
        }
    }
  
    public class ToggleRowDetailsColumnRoutedEventArgs : RoutedEventArgs {
  
        public GridViewCell Cell { get; set; }
  
        public GridViewRow Row {
            get { return Cell.ParentRow as GridViewRow; }
        }
  
        public ToggleRowDetailsColumnRoutedEventArgs( RoutedEvent routedEvent, GridViewCell cell )
            : base( routedEvent ) {
            Cell = cell;
        }
    }
  
    public delegate void ToggleRowDetailsColumnRoutedEventHandler( object sender, ToggleRowDetailsColumnRoutedEventArgs e );
}

Tony
Tony
Top achievements
Rank 1
 answered on 16 Apr 2012
2 answers
335 views
I have a RadDataForm, with a DataFormDataField, that is bound to a Decimal property.

I'm trying to get validation working, and I'm having some issues:

  1. When I have a validation error, and the DataFormDataField does not have its Label property set, the error is displayed using the name of the field, instead of the [Display(Name="xxx")] annotation.
  2. When I enter invalid characters (non-numeric), my Decimal property's setter is never called, instead the form displays a "Value 'xxx' could not be converted" error. I need to display a more meaningful message.
  3. I have a listener on the RadDataForm's ValidatingItem event - but that event is not called when I move focus from one field to another (which is when the above error messages appear.)
  4. I need to some level of validation on each keystroke. If the field can only hold 12 characters, an attempt to type a 13th should do nothing. If the user is typing in a field that can only hold numeric values, typing non-numeric characters should do nothing - the keyboard event should be swallowed, and the character should not appear in the field.  At a minimum, letters would be filtered, it'd be better if we could look at the new character and the existing content, and decide whether the new character can be applied without invalidating the field.  (If the field is bound to a decimal, it should allow numbers, and one decimal point. A second decimal point should be swallowed.)
Jeff
Top achievements
Rank 1
 answered on 16 Apr 2012
0 answers
135 views
Hi,
I would like to change the +/- symbol on a GridViewToggleRowDetailsColumn so i have created below ControlTemplate
<ControlTemplate x:Key="GridViewToggleButtonTemplate" TargetType="telerik:GridViewToggleButton">
                   <Border Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                       <Border Width="80" Height="20"
                   Background="{TemplateBinding Background}"
                   BorderBrush="{TemplateBinding BorderBrush}"               
                   BorderThickness="{TemplateBinding BorderThickness}"
                   VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                           <Grid x:Name="myGrid">
                               <TextBlock Text="Details" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                           </Grid>
                       </Border>
                   </Border>
                   <ControlTemplate.Triggers>
                       <Trigger Property="IsChecked" Value="True">
                           <Setter TargetName="myGrid" Property="Background" Value="Red" />
                       </Trigger>
                   </ControlTemplate.Triggers>
  
               </ControlTemplate>
  
               <Style TargetType="telerik:GridViewToggleButton" x:Key="toggleButtonStyle">
                   <Setter Property="Template" Value="{StaticResource GridViewToggleButtonTemplate}" />
               </Style>

And applied this style in telerik:RadGridView.Columns as below
<telerik:GridViewToggleRowDetailsColumn ToggleButtonStyle="{StaticResource toggleButtonStyle}" />

But this doesn't work so please let know how do i fix this problem.
Thanks in advance.
Pravin
Top achievements
Rank 1
 asked on 16 Apr 2012
1 answer
236 views
I am using the RadGridView
And I am having few doubts (WPF thing )
1) I am making the Autogenerated columns as True then the data gets populated auomatically. But what is the thing if I have the Property in the binding collection of type BOOLEAN and I want that to be shown as CheckBox, Can this be achieved with Autogenerated columns as True.

2) I am using the printing functionality for the gridview, incase I have a dropdown in the column and how do i get the selected dropdown item from that column and print it.

3) Also how do I print images from a grid view

4) And Finally I want to do some error handling for the data in the RadGridView, I dont find any where in ur site like demo kind for the error handling thing.
Dimitrina
Telerik team
 answered on 16 Apr 2012
1 answer
80 views
I can set color to the chart axis lines for a 2D chart by setting the AxisElementBrush of the chart control just like this:

mChartControl.AxisElementBrush = new SolidColorBrush(value);

This does not work with 3D charts. How can I get the grid lines to change colors when the chart is 3D? Why is it that I am running into so many problems to get a 3D chart to act the same as a 2D chart? dll version 2011.2.920.40 Thanks, James
Sia
Telerik team
 answered on 16 Apr 2012
0 answers
142 views
Hi. I have a small problem with RadDocking that I'm hoping there is some functionality to solve. We are using the Save/Load Layout methodology for capturing the state of our RadPanes and other controls. This provides a chunk of XML that we save out and load in as required. Unlike the PersistenceManager methodology though, there seems to be no way to prevent certain properties from being added to the XML chunk that's generated when SaveLayout is called on a RadDocking control. When developers change the header of a RadPane, for instance, the change is overwritten when the XML is passed to LoadLayout (even when the RadPane's SerializationTag is changed, which is very strange). I'm wondering if there's some way of preventing the Header property from appearing in the XML, or if we need to take steps to remove it ourselves. It's either this or ignore all of the XML, and leave the controls to assume their default configuration, overwriting the XML.

Many thanks,
- Chris M.
ChrisM
Top achievements
Rank 1
 asked on 16 Apr 2012
5 answers
125 views
Hi,

We are using RadGridView, RadPanelBar, RadDataFilter, RadBusyIndicator in our application.  We need to be 508 compliant and we were under the impression that Telerik controls were compatible.  When I use Jaws e-reader, navigation panel is not read by the e-reader.  DataFilter's dropdowns are not read, either.  If a user selects a column or filteroperator, they have no idea what they chose.
GridView's headers are skipped when tabbing through and goes into the data rows.  Add new item bar is also skipped.

Is there a property or maybe a setting we need to apply to get RadControls reader ready?

Thanks,
Dimitrina
Telerik team
 answered on 16 Apr 2012
0 answers
136 views
Hi,

i'm using the radCombobox like this:

<telerik:RadComboBox Grid.Row="0" Grid.Column="1" Margin="3" telerik:StyleManager.Theme="Summer" Name="SpracheCCB" DisplayMemberPath="Name" SelectionChanged="SpracheCCB_SelectionChanged"  />

I want set the selectedItem in the codebehind like this:

this.SpracheCCB.SelectedItem = SETTINGS.aktsprache;  
or
this.SpracheCCB.SelectedItem = 1;

SETTINGS.aktsprache = "german"

But it empty every time?!?!?
Is there a "simple" Example?

thanks
regards
rene
ITA
Top achievements
Rank 1
 asked on 16 Apr 2012
1 answer
91 views

I would like to bring a row of my RadGridView into view programatically. I have a more than 100 rows. When I create a row(which I am doing by adding an item to a observable collection) I would like that new row to be selected and bring that into view. I was able to select the new row in my code but could not do the scrolling. More over I want the first cell of the row to be in edit mode so that the user can input text. I am following MVVM pattern for the application and would like to keep zero code in my views. How Can I achieve this?

Any help or suggestion will be appreciated....

Here is some of my code

XAML

<telerik:RadGridView ItemsSource="{Binding AllPartClasses}" 
                     
SelectedItem="{Binding SelectedPartClassViewModel, Mode=TwoWay}"        
                     
SelectionMode="Single" IsSynchronizedWithCurrentItem="True">

in my view model I did this

void AddNewPartClassExecute()
    {
        PartClass newPartClass = new PartClass();
        PartClassViewModel tempPartClass = new PartClassViewModel(newPartClass);
        tempPartClass.IsInValid = true;
        AllPartClasses.Add(tempPartClass);
        SelectedPartClassViewModel = tempPartClass;
        Global.DbContext.PartClasses.AddObject(newPartClass);

        //OnPropertyChanged("AllPartClasses");
    }
public PartClassViewModel SelectedPartClassViewModel
    {
        get
        {  
            return _selectedPartClassViewModel;
        }
        set
        {
            _selectedPartClassViewModel = value;
            OnPropertyChanged("SelectedPartClassViewModel");
        }
    }

Dimitrina
Telerik team
 answered on 16 Apr 2012
2 answers
111 views
I am using RadTreeListView, provided the Xaml below.
I wanted to do validation for the text box column, similar to what is provided for GridView column, 'CellValidating' event where if validation logic fails, text box shows a comment, and the border will become red. Is this supported in RadTreeListView, how can I implement in my code?

 <telerik:RadTreeListView x:Name="MyTree" AutoGenerateColumns="False">
 <telerik:RadTreeListView.Columns>
                    <telerik:GridViewDataColumn x:Name="ObjNameColumn" Header="Name" DataMemberBinding="{Binding Name}" >
                        <telerik:GridViewDataColumn.CellStyle>
                            <Style TargetType="telerik:GridViewCell">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <Border BorderBrush="LightGray" BorderThickness="0,0,1,0">
                                                <TextBox x:Name="txtBox_NewInstanceName"                                                   
                                                           HorizontalAlignment="Center" VerticalAlignment="Center"    
                                                            Text="{Binding Path=Name, Mode=TwoWay, UpdateSourceTrigger=LostFocus}">
                                                </TextBox>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </telerik:GridViewDataColumn.CellStyle>
                    </telerik:GridViewDataColumn>
...
...


Smita
Top achievements
Rank 1
 answered on 16 Apr 2012
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?