Telerik Forums
UI for WPF Forum
0 answers
96 views

I sent a support ticket to the telerik admins asking if there were any API methods to determine if the caret is at the start and end of a line.
They responded with a solution so I thought I should share it with everyone else.

Is Caret at Line Start

public static bool IsCaretAtLineStart(RadDocument document)
{
    DocumentPosition endLinePosition = new DocumentPosition(document.CaretPosition);
    endLinePosition.MoveToCurrentLineStart();
 
    if (document.CaretPosition == endLinePosition)
    {
        return true;
    }
 
    return false;
}


Is Caret at Line End

public static bool IsCaretAtLineEnd(RadDocument document)
{
    DocumentPosition endLinePosition = new DocumentPosition(document.CaretPosition);
    endLinePosition.MoveToCurrentLineEnd();
 
    if (document.CaretPosition == endLinePosition)
    {
        return true;
    }
 
    return false;
}


I hope this helps you as it did myself.

Thanks,

Rob

Robert
Top achievements
Rank 1
 asked on 07 May 2012
5 answers
1.8K+ views
Hi,

I'm trying to use the RadMaskedNumericInput as follows;

<telerik:RadMaskedNumericInput
                Grid.Row="6"
                Grid.Column="1"
                Value="{Binding Mileage}"
                EmptyContent="kilometer"
                FormatString="D"
                Mask="d"
                IsClearButtonVisible="False"
                VerticalAlignment="Center"
                VerticalContentAlignment="Center"
                />

...where the bound 'Mileage'-property is an Int. But when I try to input a number at runtime, I get the following exception;

"Index was outside the bounds of the array."

And the stacktrace;

   at System.String.get_Chars(Int32 index)
   at Telerik.Windows.Controls.RadMaskedNumericInput.GetValidCharOverride(Char ch, Int32& position, Nullable`1 forwardSpin, Boolean& isValid) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedNumericInput.cs:line 625
   at Telerik.Windows.Controls.RadMaskedInputBase.ProcessChar(Char ch, Int32& position, Nullable`1 forwardSpin) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.cs:line 2693
   at Telerik.Windows.Controls.RadMaskedInputBase.ProcessChar(Char ch, Int32 position, TokenTypes type, Nullable`1 forward, Nullable`1 forwardSpin) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.cs:line 2641
   at Telerik.Windows.Controls.RadMaskedInputBase.ProcessKey(Char ch, KeyEventArgs args) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.cs:line 1548
   at Telerik.Windows.Controls.RadMaskedInputBase.OnKeyDownHandled(Char c) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\RadMaskedInputBase.cs:line 476
   at Telerik.Windows.Controls.MaskedInput.PreviewInputTextBox.OnTextInput(TextCompositionEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\MaskedInput\PreviewInputTextBox.cs:line 44
   at System.Windows.UIElement.OnTextInputThunk(Object sender, TextCompositionEventArgs e)
   at System.Windows.Input.TextCompositionEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.TextCompositionManager.UnsafeCompleteComposition(TextComposition composition)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.TextCompositionManager.UnsafeStartComposition(TextComposition composition)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessTextInputAction(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
.... 
Tina Stancheva
Telerik team
 answered on 07 May 2012
2 answers
257 views
Hi,

I have two questions, first i have a button in a column, but when a put the gridview in readonly, the button continues the same.

How i can put the button in readonly mode? This is the code.
<telerik:RadGridView x:Name="myListView" IsReadOnly="{Binding Path=pending, Converter={StaticResource booleanToInverseConv}}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewColumn Header="" IsFilterable="False" HeaderCellStyle="{StaticResource estiloDaColuna}">
            <telerik:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <Button Style="{DynamicResource ImageButtonStyle}" Tag="{Binding Path=id}" x:Name="btnRemoveProduto" Width="20" Click="removeProduto_Click" Height="20">
                        <Image Source="..\..\..\Icons\delete_red.png" Stretch="Fill" VerticalAlignment="Top" HorizontalAlignment="Left" />
                    </Button>
                </DataTemplate>
            </telerik:GridViewColumn.CellTemplate>
        </telerik:GridViewColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Second question, i want bind a business property in a column footer,
<telerik:GridViewDataColumn IsFilterable="False" IsReadOnly="True" Header="Desconto 2" DataMemberBinding="{Binding desconto2}" DataFormatString="{}{0:N2}%" Width="90" HeaderCellStyle="{StaticResource estiloDaColuna}" FooterCellStyle="{StaticResource GridViewCellStyleLeft}">
                                    <telerik:GridViewDataColumn.Footer>
                                        <StackPanel>
                                            <Label Content="Ola"></Label>
                                            <Label Content="{Binding Path=Descontos}"></Label>
                                        </StackPanel>
                                    </telerik:GridViewDataColumn.Footer>

Making that only appears the word "ola", the value in "Descontos" is not show. How can resolve it?

Thanks
Tiago
Top achievements
Rank 1
 answered on 07 May 2012
3 answers
301 views
When I insert a large jpeg into the richtextbox, the editor chops off the right side of the image to fit into the richtextbox without a horizontal scrollbar.  What I need is a way to make the richtextbox expands to fit the image.

<
telerik:RadRichTextBox HorizontalAlignment="Stretch" LayoutMode="Flow" x:Name="editor" AllowDrop="True" Drop="editor_Drop" ShowComments="False"
                        BorderBrush="Transparent" BorderThickness="0" IsSelectionMiniToolBarEnabled="False"
                        IsContextMenuEnabled="True" IsInHeaderFooterEditMode="False" DocumentPresentationChanged="EditorDocumentContentChanged"
                        LostFocus="editor_LostFocus" SizeChanged="editor_SizeChanged" HorizontalScrollBarVisibility="Disabled">
</telerik:RadRichTextBox>

private void editor_SizeChanged(object sender, SizeChangedEventArgs e)
{
    this.editor.UpdateEditorLayout();
}

Ivailo Karamanolev
Telerik team
 answered on 07 May 2012
1 answer
150 views

Hi,

It is somehow possible to display/edit an EntityCollection of entities?

My entity looks like that:

public partial class Property : EntityObject
{....
  public string Name {set;get}
  public string Description {set;get}
  public string Value{set;get}
  public string RegExValidationString{set;get}
}

And I want to be able to edit a collection, each object in the collection to be displayed as an row in the PropertyGrid:

EntityCollection<Property> entityCollection = new EntityCollection<Property>();
entityCollection.Add(new Property() { Name = "test1", Description = "test1 description", Value = "111" });
entityCollection.Add(new Property() { Name = "test2", Description = "test2222 description", Value = "lallla" });
I tried by adding PropertyDefinitions, but I'm not able to edit values:

foreach (Property p in entityCollection)
{
    PropertyDefinition pd = new PropertyDefinition() 
    
        Binding = new Binding { Source = p.Value }, 
        DisplayName = p.Name, 
        Description = p.Description 
    };                
 
    radPropertyGrid.PropertyDefinitions.Add(pd);
}
Is there another way to do this? Do you have any examples?

albu
Top achievements
Rank 1
 answered on 07 May 2012
0 answers
125 views
  • Hi  Maya,

Please do reply to the below thread chain with sample application...

I just want to appply alternate grid row color for telerik:RadGridView  

instead of applying the following property in tag,
<telerik:RadGridView AlternateRowBackground="Aqua" AlternationCount="2"/>

 i want to do the same in common settings (resource dictionary)

Please advice me ASAP.
Mohamed
Top achievements
Rank 1
 asked on 07 May 2012
0 answers
132 views
Hi Team,

I have few requirements/solutions.

Requirement 1# : I have a custom Row Style, as shown in image attached. 
                            On Expansion/Collapase of row in Hirerchy grid, above mentioned row style should be applied.

Please find the attachement.

    
                           
Prakash
Top achievements
Rank 1
 asked on 06 May 2012
0 answers
76 views
Hi,

is it possible to drop in any position of a control? In a ListView the droppped items are in a line, but i want to drop them
somewhere in the crontrol i want, is tha possible and how?

Thanks
regards
Rene
ITA
Top achievements
Rank 1
 asked on 06 May 2012
1 answer
78 views
HI

 I am  using Radgridview in my first column binding the Combox Intemsource. second column is data column i want to bind the data  for second column based on the first column selection.

eg)
Gridview
First column displaying Country  code  (drop down)
second column should display the  country name based on the drop down selection.
I am using MVVM model

 can you help me  i checked telerik article but icouldnotable to achive..

regards
murugan
smith
Top achievements
Rank 1
 answered on 06 May 2012
0 answers
75 views
hi , I have done as per your doc shown here.
But I cannot get the add and delete buttons to show in the rad data form. i even tried implementing ieditable object etc. There is some complicated forum thread regarding implementing icollectionview etc. All I need is the add and delete buttons to show in addition to showing the raddataform in edit mode. (ok button enabled). I tried
<telerik:RadDataForm CurrentItem="{Binding CurrentItem,ElementName=RadGridView1}" 
no luck so far. Any simple solution to this ?
thankyou
Geena
Top achievements
Rank 1
 asked on 04 May 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?