Telerik Forums
UI for WPF Forum
3 answers
1.0K+ views
I am using telerik radgridview to bind to a collection of my model objects. Also, have added a validation rule class that triggers the validation.


Now i want to show a validation error around the radgridview row in case the error occurs. An custom error template is defined in my resource file.  Below is the xaml for the same.


    <telerik:RadGridView Grid.Column="0" Grid.Row="2"                                  ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                 ItemsSource="{Binding Path=CollectionOfObjects}" SelectedItem="{Binding Path=SelectedObject, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                                 GdEvent:DoubleClickGridViewCommandBehaviour.OnDoubleClick="{Binding Path=GridRowDoubleClickCommand}" 
                                 RowIndicatorVisibility="Collapsed" ColumnWidth="*" EditTriggers="None" IsFilteringAllowed="False" 
                                 AutoGenerateColumns="False" AllowDrop="False" 
                                 CanUserFreezeColumns="False" CanUserReorderColumns="False" 
                                 CanUserDeleteRows="False" CanUserInsertRows="False" ShowGroupPanel="False" 
                                 SelectionMode="Single" SelectionUnit="FullRow">
    <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Width="Auto" Header="Header1" DataMemberBinding="{Binding Header1}" TextAlignment="Left"/>
                    <telerik:GridViewDataColumn Width="Auto" Header="Header2" DataMemberBinding="{Binding Header2}" TextAlignment="Left"/>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.BindingGroup>
      <BindingGroup NotifyOnValidationError="True">
       <BindingGroup.ValidationRules>
         <util2:ModelValidationRule ValidationStep="ConvertedProposedValue" ValidatesOnTargetUpdated="True" />
       </BindingGroup.ValidationRules>
      </BindingGroup>


But when i run the app, an the validation error fails. it is not showing any error against that row.


Please help
     </telerik:RadGridView.BindingGroup>
    <telerik:RadGridView.Resources>
     <Style TargetType="{x:Type telerik:GridViewRow}">
       <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
       <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ErrorTemplate}"/>
     </Style>
    </telerik:RadGridView.Resources>
Nedyalko Nikolov
Telerik team
 answered on 19 May 2012
5 answers
253 views
Hi,

I'm interested in recreating an existing UI using the RadDock with a splitter and RadPane objects.  I have nearly everything I need through existing properties but I could use some advice on how to achieve a particular effect.  (see Desired.png - attached)

In a given RadPane, I set the Contents during the ElementLoading event. But, the element which becomes the RadPane's child is responsible in our app for creating the particular tool buttons we want to show within the Title/Header.

For the Recent Files pane I show, the folder and two filter buttons are created by the same UserControl responsible for the list. 

I'd like to create something like this for my TitleTemplate -- this does not work -- clearly the binding needs work.

<DataTemplate x:Key="TitleTemplate">
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="*" />
             <ColumnDefinition Width="Auto" />
             <ColumnDefinition />
         </Grid.ColumnDefinitions>
         <ContentPresenter Content="{Binding}" 
                       Name="titleTemplate"
                       Margin="0,0,0,0"/>
         <ContentPresenter Content="{Binding Path=SelectedPane.Content.ToolStack, 
             RelativeSource={RelativeSource AncestorType=FrameworkElement}}" 
                           Name="toolStackHolder" 
                           Margin="0" />
     </Grid>
 </DataTemplate>

<telerik:RadPaneGroup>
    <telerik:RadPane 
        telerik:RadDocking.SerializationTag="RecentFilesPane"
        ContextMenuTemplate="{x:Null}"
        TitleTemplate="{StaticResource ResourceKey=TitleTemplate}" 
        Header="Recent Files"
        CanUserPin="True">
        <!-- CONTENT FILLED DYNAMICALLY -->
    </telerik:RadPane>
</telerik:RadPaneGroup>


The first ContentPresenter should be for the Title and I'll fixup the formatting, font, etc. later to match my requirements.

The second ContentPresenter is where I'd like to have the object which is within the RadPane to supply a FrameworkElement such as a StackPanel or Toolbar or ToolbarTray etc.. based onthe particular pane.

Can anyone suggest a way for me to bind to a property on that object within the TitleTemplate?  Here, I invented one called "ToolStack" which my usercontrol list object implements -- but it's not bound to of course...

John

Miroslav Nedyalkov
Telerik team
 answered on 19 May 2012
1 answer
234 views
Hi..
I have RadButton in a DataTemplate in a ListView. I have a command bound to the button that works fine.
But when I click my button, without selecting the row - i need to get the current row - how can I get the SelectedItem of the current ListView Row when the RadButton is clicked.   For example I want to name the Button REMOVE and remove the current row - without having to click 'behind' the RadButton to select the row to be deleted. first.
thanks!!!!!!!!!!!!!!!!!


<

 

 

ListView x:Name="lstRangeColors" Width="225" MaxHeight="275" ScrollViewer.VerticalScrollBarVisibility="Visible" Margin="0,0,0,0" ItemsSource="{Binding Path=Filters.RangeColors}" SelectedItem="{Binding Path=RangeColor}">

 

 

<ListView.ItemTemplate>

 

 

<DataTemplate>

 

 

<ContentPresenter Margin="5,5,5,5" Content="{Binding}">

 

 

<ContentPresenter.ContentTemplate>

 

 

<DataTemplate>

 

 

<Grid x:Name="gridContent" Height="35" VerticalAlignment="Stretch">

 

 

<Grid.ColumnDefinitions>

 

 

<ColumnDefinition Width="20*"/>

 

 

<ColumnDefinition Width="60*"/>

 

 

<ColumnDefinition Width="40*"/>

 

 

</Grid.ColumnDefinitions>

 

 

<Grid.RowDefinitions>

 

 

<RowDefinition Height="30" />

 

 

</Grid.RowDefinitions>

 

 

<CheckBox Grid.Row="0" Grid.Column="0" Width="40" IsChecked="{Binding RangeValue.IsSelected, Mode=TwoWay}" Margin="5,5,0,0"/>

 

 

<TextBox Grid.Row="0" Grid.Column="1" BorderBrush="Navy" BorderThickness="1" Width="40" Text="{Binding RangeValue, Mode=TwoWay}" Margin="15,0,0,0" FontSize="14" />

 

 

<<telerik:RadButton Grid.Row="0" Grid.Column="2" Height="30" Background="{Binding BlockColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=DataContext.SelectColorCommand}" HorizontalAlignment="Left" Margin="25,0,0,0" Name="btnColor" Width="40" />

 

 

</Grid>

 

 

</DataTemplate>

 

 

</ContentPresenter.ContentTemplate>

 

 

</ContentPresenter>

 

 

</DataTemplate>

 

 

</ListView.ItemTemplate>

 

 

</ListView>


Zarko
Telerik team
 answered on 18 May 2012
3 answers
142 views
Hello,

I have a user control that contains a text box and a search button. This user control has been added to a RadMenu as follows:

 <telerik:RadMenu HorizontalAlignment="Stretch" DataContext="{Binding SimpleSearchViewModel}">
            <telerik:RadMenu.ItemsPanel>
                <ItemsPanelTemplate>
                    <DockPanel HorizontalAlignment="Stretch" />
                </ItemsPanelTemplate>
            </telerik:RadMenu.ItemsPanel>
            <telerik:RadMenu.Items>
                <telerik:RadMenuItem Header="Menu1" /> 
                <telerik:RadMenuItem Header="Menu2" />  
                <telerik:RadMenuItem HorizontalAlignment="Right">
                    <telerik:RadMenuItem.Header>
                        <searchctrls:SimpleSearchView />
                    </telerik:RadMenuItem.Header>
                </telerik:RadMenuItem>

            </telerik:RadMenu.Items>
</telerik:RadMenu>

This seems to work fine. The problem I am experiencing is that when the user control (SimpleSearchView) is focused, say, with the cursor in the textbox, it takes two (2) clicks to close the application using the "X" at the corner of the window. This behavior does not seem to appear with any other UI item in my application, i.e. I can focus the textbox in the SimpleSearchView control and then click another menu item without a problem.

Could you help me resolve this issue?

Let me know if a separate sample project would be helpful.

Many thanks
Simon
Top achievements
Rank 1
 answered on 18 May 2012
4 answers
106 views
Hi,

in my application, I have 3 possible contexts: Exports, Reports and Sessions. In my application I have only one RadGridView and the RadGridView layout change regarding the current active context. Regarding the context, the grid have differents converters for columns who contains enumeration values.

Before changing the grid layout, I call the following methods:

    - GV.GroupDescriptors.Clear()
    - GV.SortDescriptors.Clear()
    - GV.FilterDescriptors.Clear()

I don`t know why but when I switch from one context to another, after I change the layout of my grid, if I go on a column which contain a converter for my enumeration, I click on the filter dialog button, when the filter dialog appear, in the top part of the filter dialog, I have all existing values in my columns that I can check or uncheck but when I click in the combobox to apply a specific filter, the values in the dropdown it's the value corresponding to my previous context.

Thank's
Oliver
Top achievements
Rank 1
 answered on 18 May 2012
1 answer
177 views
I have a reference in my xaml as such:
xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input"

I am trying to set the Minimum value in the style as such:
        <Style x:Key="RadMaskedCurrencyInputStyle" TargetType="telerik:RadMaskedCurrencyInput">
            <Setter Property="maskedInput:MaskedInputExtensions.Minimum" Value="0" />
        </Style>

This throws an exception at run time:  
System.Windows.Markup.XamlParseException occurred
  Message='Set property 'System.Windows.Setter.Property' threw an exception.' Line number '10' and line position '14'.
  Source=PresentationFramework
  LineNumber=10
  LinePosition=14
  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 TestRadControl.MainWindow.InitializeComponent() in ...\Documents\Visual Studio 2010\Projects\TestRadControl\TestRadControl\MainWindow.xaml:line 1
       at TestRadControl.MainWindow..ctor() in ...2010\Projects\TestRadControl\TestRadControl\MainWindow.xaml.cs:line 25
  InnerException: System.ArgumentNullException
       Message=Value cannot be null.
Parameter name: property
       Source=PresentationFramework
       ParamName=property
       StackTrace:
            at System.Windows.Setter.CheckValidProperty(DependencyProperty property)
            at System.Windows.Baml2006.WpfSharedBamlSchemaContext.<Create_BamlProperty_Setter_Property>b__1c0(Object target, Object value)
            at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
       InnerException: 


Is this a flaw with Telerik's implementation of the Minimum dependency property?  I am using version 2011 SP1.

Thanks,
Monica
Tina Stancheva
Telerik team
 answered on 18 May 2012
1 answer
106 views
Hello,

I have my application in "pt-PT" culture, and have this column.

<telerik:GridViewDataColumn IsSortable="False" IsFilterable="False" Header="Preço Unitário" DataMemberBinding="{Binding PrecoUnitario}"
DataFormatString="{}{0:C}" MinWidth="60" MaxWidth="100" HeaderCellStyle="{StaticResource estiloDaColuna}"/>

introducing "20.2", it places "202,00".
introducing "20,2" it places "20,20".

In "en-US" culture works well.

So, how can i give the same behavior for dot and comma?

Thanks
Dimitrina
Telerik team
 answered on 18 May 2012
0 answers
125 views
Hi,
I need a sample code for to create the parent and child grid.
Regards
Rajini
Rajini
Top achievements
Rank 1
 asked on 18 May 2012
0 answers
87 views
Here is a code sample that gets the Type Of the Next & Previous Annotation at the caret position.
.
Get TypeOf Next Annotation:
public static AnnotationRangeMarkerBase GetNextAnnotationMarker(this RadDocument document)
{
    if (!document.Selection.IsEmpty)
    {
        document.CaretPosition.MoveToPosition(document.Selection.Ranges.Last.EndPosition);
    }
 
    InlineLayoutBox inlineLayoutBox = document.CaretPosition.GetCurrentInlineBox();
    while (inlineLayoutBox != null && !(inlineLayoutBox.AssociatedInline is AnnotationRangeMarkerBase))
    {
        inlineLayoutBox = (InlineLayoutBox)DocumentStructureCollection.GetNextElementOfType(inlineLayoutBox, typeof(AnnotationMarkerLayoutBox));
    }
 
    if (inlineLayoutBox == null)
    {
        return null;
    }
 
 
    AnnotationRangeMarkerBase annotationMarker = inlineLayoutBox.AssociatedInline as AnnotationRangeMarkerBase;
    if (annotationMarker == null)
    {
        return null;
    }
 
    return annotationMarker;
}


Get TypeOf Previous Annotation:
public static AnnotationRangeMarkerBase GetPreviousAnnotationMarker(this RadDocument document)
{
    if (!document.Selection.IsEmpty)
    {
        document.CaretPosition.MoveToPosition(document.Selection.Ranges.Last.StartPosition);
    }
 
    InlineLayoutBox inlineLayoutBox = document.CaretPosition.GetCurrentInlineBox();
    do
    {
        inlineLayoutBox = (InlineLayoutBox)DocumentStructureCollection.GetPreviousElementOfType(inlineLayoutBox, typeof(AnnotationMarkerLayoutBox));
    }
    while (inlineLayoutBox != null && !(inlineLayoutBox.AssociatedInline is AnnotationRangeStart));
 
    if (inlineLayoutBox == null)
    {
        return null;
    }
 
    return inlineLayoutBox.AssociatedInline as AnnotationRangeMarkerBase;
}


This is how you can use the methods:
//Get the previous annotation type
AnnotationRangeMarkerBase previousAnnotationType = RadDocumentExtensions.GetPreviousAnnotationMarker(radRichTextBox.Document);
 
 
//Get the next annotation type
AnnotationRangeMarkerBase nextAnnotationType = RadDocumentExtensions.GetNextAnnotationMarker(radRichTextBox.Document);

I hope this help you as it did me.

p.s. This code was mostly given to me by the Telerik support team via a ticket that I sent.
Robert
Top achievements
Rank 1
 asked on 18 May 2012
1 answer
176 views
I have a column in my RadGridView that displays some text and then also contains a button that should only be visible to users with permission to change the data.  I'm using MVVM and the viewmodel exposes a boolean property named UserHasWriteAccess that indicates the user's permission level.  The column and its datatemplate are defined as follows.

<telerik:GridViewDataColumn Header="Reason Code">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
 
                <TextBlock Text="Lorem ipsum" />
                <Button Content="Edit"
                        Height="23"
                        HorizontalAlignment="Right"
                        Margin="4,0,0,0"
                        Visibility="{Binding DataContext.UserHasWriteAccess,
                                    Mode=OneTime,
                                    Converter={StaticResource BooleanToVisibilityConverter},
                                    RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}">
            </Grid>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

When UserHasWriteAccess is false, the button's visibility binding works fine most of the time (~99%) and the button does not show.  However, as the user scrolls up and down through the grid, eventually intermittent binding errors will suddenly appear for a row or two for which the binding worked previously.  Sometimes the user has to scroll up and down several times before it happens.  Other times it's immediate.  The errors say:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Telerik.Windows.Controls.RadGridView', AncestorLevel='1''. BindingExpression:Path=DataContext.UserHasWriteAccess; DataItem=null; target element is 'Button' (Name=''); target property is 'Visibility' (type 'Visibility')

Curiously, when I inspect an errored binding using Snoop, it suddenly works again.

Is there a known issue with ancestor binding in RadGridView?
Pavel Pavlov
Telerik team
 answered on 18 May 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
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?