Telerik Forums
UI for WPF Forum
5 answers
82 views
Seems that GroupHeaderTemplate doesn't use the Converter set in the GroupDescription?
How can I make a template that does?
Dimitrina
Telerik team
 answered on 19 Dec 2014
1 answer
40 views
Steps to reproduce:
1. create the following lines of text:
line 1
line 2
line 3

2. select "line 1" and indent it to the right ; it results in one step indentation
3. select both "line 2" and "line 3" and indent them to the right;  it results in two step indentation
Aylin
Telerik team
 answered on 19 Dec 2014
4 answers
219 views
Howdy Everyone,

I'd like to ask on how to hide/show telerik grids on the same window by clicking a button?

Here's my scenario: 
I have 3 buttons: the day, week and month. My default grid on the window is the Day Grid. When I clicked on the day button, the day grid would show up, when the week button is clicked, the week grid will and the day grid will hide, and lastly, when the month button is clicked, the month grid will show and the week grid will be hidden. Please help me since i'm new to your tools. Would greatly appreciate your help. God bless.

Ayana
Ben
Top achievements
Rank 1
 answered on 18 Dec 2014
2 answers
400 views
If I click the "Click here to add new item" row in my gridview, a new row appears as expected. However, as soon as I click anywhere other than on the new row (triggering RowEditEnded), the new row disappears from the gridview and the "Click here to add new item" row replaces it.

If I then save changes, the invisible row DOES save to the database and re-appears after a refresh. In other words, while the row disappears visually from the grid, it still exists in the datasource the grid binds to and is valid enough to save.

If I repeat the actions in the first paragraph 10 times and then save changes, 10 invisible rows will save to the database and reappear after a refresh.

What is going on here???

The gridview::

<telerik:RadGridView
    x:Name="LoanGrid"
    ItemsSource="{Binding Loans}"
    IsBusy="{Binding AreLoansBusy}"
    CanUserSelect="{Binding CanUserSelectLoans}"
    SelectedItem="{Binding SelectedLoan, Mode=TwoWay}"
    Margin="10,-6,10,10"
    GroupRenderMode="Flat"
    IsReadOnly="{Binding UserHasProjectRole, Converter={StaticResource NegationConverter}}"
    ColumnWidth="*"
    CanUserInsertRows="{Binding UserHasProjectRole}"
    SelectionMode="Single"
    NewRowPosition="Bottom"
    AutoGenerateColumns="False"
    IsSynchronizedWithCurrentItem="True"
    ShowGroupPanel="False"
    IsFilteringAllowed="False"
    ValidatesOnDataErrors="InEditMode"
    ActionOnLostFocus="CommitEdit"
    Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
 
    <telerik:RadGridView.Columns>
        <telerik:GridViewComboBoxColumn
            Header="Loan Type"
            IsReadOnly="False"
            DataMemberBinding="{Binding LoanTypeId}"
            SelectedValueMemberPath="Id"
            DisplayMemberPath="Description"
            ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.LoanTypes}"
            Width="Auto" />
        <telerik:GridViewDataColumn
            UniqueName="ApplicationAmount"
            Header="Application Amount"
            DataMemberBinding="{Binding ApplicationAmount, StringFormat=c2}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Total Project Costs"
            DataMemberBinding="{Binding TotalProjectCosts, StringFormat=c2}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Eligible Project Costs"
            DataMemberBinding="{Binding EligibleProjectCosts, StringFormat=c2}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Interest Rate"
            DataMemberBinding="{Binding InterestRate, StringFormat='{}{0}%'}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Indenture"
            DataMemberBinding="{Binding Indenture}"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="EFC Bond Series"
            DataMemberBinding="{Binding EfcBondSeries}"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Auditing"
            IsReadOnly="True"
            Width="Auto">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding LastUpdatedBy}" />
                        <TextBlock Text="{Binding LastUpdatedDate, StringFormat=g}" Margin="5 0 0 0" />
                    </StackPanel>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
 
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="RowEditEnded">
            <infrastructure:InvokeDelegateCommandAction
        Command="{Binding LoanRowEditEndedCommand}"
        CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="Deleting">
            <infrastructure:InvokeDelegateCommandAction
        Command="{Binding LoanRowDeletingCommand}"
        CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="RowValidating">
            <infrastructure:InvokeDelegateCommandAction
        Command="{Binding LoanRowValidatingCommand}"
        CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</telerik:RadGridView>

The bound data source:

public QueryableDataServiceCollectionView<ProjectPhaseLoan> Loans { get; private set; }

Greg
Top achievements
Rank 1
 answered on 18 Dec 2014
4 answers
253 views
My application stores many small snippets of information in docx format. The individual information snippets must be stored internally in a way that can be easily accessed as a byte array (IList<byte> and ToArray() works). Another requirement is that the application be able to collate snippets into a document which can be exported.

I am able to use a DocxFormatProvider to import individual snippets to a RadFlowDocument, and can then use the Merge method of RadFlowDocument as necessary to achieve the desired result.

However, I am unable to import a snippet that is the result of the Merge method, if that snippet has been edited from inside a RadRichTextBox. Below is code to reproduce the issue.

MainWindow.xaml:
<Window x:Class="TelerikDocxManipulationTest.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="800" Width="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
 
        <telerik:DocxDataProvider x:Name="DocxDataProvider"
                                  RichTextBox="{Binding ElementName=DataInput}"
                                  Docx="{Binding Data, Mode=TwoWay}">
        </telerik:DocxDataProvider>
 
        <StackPanel Orientation="Horizontal">
            <Button Grid.Column="1" Width="100" Margin="10,0,0,0" Click="Import">
                <TextBlock>
                    Import
                </TextBlock>
            </Button>
            <Button Grid.Column="1" Width="100" Margin="10,0,0,0" Click="Merge">
                <TextBlock>
                    Merge
                </TextBlock>
            </Button>
            <Button Grid.Column="1" Width="100" Margin="10,0,0,0" Click="Export">
                <TextBlock>
                    Export
                </TextBlock>
            </Button>
        </StackPanel>
         
        <telerik:RadRichTextBox x:Name="DataInput"
                                Grid.Row="1"
                                IsSpellCheckingEnabled="False"
                                HorizontalScrollBarVisibility="Hidden"
                                VerticalScrollBarVisibility="Visible"
                                LayoutMode="Paged"/>
    </Grid>
</Window>

MainWindow.xaml.cs:
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using Telerik.Windows.Documents.Flow.FormatProviders.Docx;
using Telerik.Windows.Documents.Flow.Model;
using Telerik.Windows.Documents.Flow.Model.Collections;
 
namespace TelerikDocxManipulationTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window, INotifyPropertyChanged
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
        }
 
        /// <summary>
        /// Telerik DocxFormatProvider
        /// </summary>
        private DocxFormatProvider provider = new DocxFormatProvider();
 
        /// <summary>
        /// The binary data for the docx file
        /// </summary>
        private IList<byte> mData = new List<byte>();
        public IList<byte> Data
        {
            get
            {
                return mData;
            }
            set
            {
                mData = value;
                OnPropertyChanged("Data");
            }
        }
 
        /// <summary>
        /// Import a docx file from disk
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Import(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "docx files (*.docx)|*.docx";
            dialog.RestoreDirectory = true;
 
            if (dialog.ShowDialog() == true)
            {
                try
                {
                    Data = File.ReadAllBytes(dialog.FileName).ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 
        /// <summary>
        /// Merge the current document with a docx document from disk
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Merge(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "docx files (*.docx)|*.docx";
            dialog.RestoreDirectory = true;
 
            if (dialog.ShowDialog() == true)
            {
                try
                {
                    RadFlowDocument existingDocument = provider.Import(Data.ToArray());
                    RadFlowDocument mergeDocument = provider.Import(dialog.OpenFile());
 
                    existingDocument.Merge(mergeDocument);
 
                    Data = provider.Export(existingDocument).ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 
        /// <summary>
        /// Export the current file data to disk
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Export(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "docx";
            dialog.Filter = "docx files (*.docx)|*.docx";
            dialog.RestoreDirectory = true;
 
            if (dialog.ShowDialog() == true)
            {
                using (Stream output = dialog.OpenFile())
                {
                    try
                    {
                        output.Write(Data.ToArray(), 0, Data.Count);
                        MessageBox.Show("Document exported.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
 
 
        #region INotifiedProperty Block
        public event PropertyChangedEventHandler PropertyChanged;
 
        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
 
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}

Here are the steps to follow to reproduce the issue:

1) Open a docx file by clicking "Import"
2) Append a second docx file by clicking "Merge"
3) Edit the resulting document inside the RTB.
4) Append a third docx file by clicking "Merge"

An exception will be thrown at line 86 in MainWindow.xaml.cs by:
RadFlowDocument existingDocument = provider.Import(Data.ToArray());

The exception is:
"The given key was not present in the dictionary."



Also, I would be very grateful for any information about how I might remove the line break inserted between documents by the Merge method. When merging documents, there does not appear to be any line break in the RadRichTextBox. However, after clicking "Export" and saving the document, line breaks appear between the merged documents in Word.
Ricky
Top achievements
Rank 1
 answered on 18 Dec 2014
3 answers
717 views
Hi Team,
Please refer to the attachment "Enter key and Shift + Enter keys behavior.png". Please refer to the steps, I followed
1) Typed "firstline in paragraph1"
2) Pressed ENTER Key (it creates a new Paragraph)
3) Typed "second line in paragraph2"
Actual Result : Pressing ENTER key creates a new paragraph, so we have extra line space
Expected Result : If we press ENTER key, Can we have next line in same paragraph (without line space)

4) Typed "para 3 abcd"
5) Pressed SHIFT key + ENTER key
6) Typed "efgh"
Actual Result : Pressing SHIFT key + ENTER key creates a next line in same paragraph.
Expected Result : If we press SHIFT key + ENTER key, Can we have next line in NEW paragraph

I have tried the below approaches however no luck.
void utdRichTextEditor_PreviewEditorKeyDown(object sender, PreviewEditorKeyEventArgs e)
{
 if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
      &&
      Keyboard.IsKeyDown(Key.Enter))
      {
      e.SuppressDefaultAction = true;
      }
      else if (Keyboard.IsKeyDown(Key.Enter))
      {
      e.SuppressDefaultAction = true;
        ((RadRichTextBox)sender).InsertLineBreak();
      }
}

private void SetLineSpacing()
{
 myRadRichTextBox.Document.LineSpacingType = LineSpacingType.Exact;
 myRadRichTextBox.DocumentInheritsDefaultStyleSettings = true;

 myRadRichTextBox.Document.LineSpacing = 0;
 myRadRichTextBox.Document.ParagraphDefaultSpacingAfter = 0;
 myRadRichTextBox.Document.ParagraphDefaultSpacingBefore = 0;
}

Thanks,
Obuliraj Ramalingam



Tanya
Telerik team
 answered on 18 Dec 2014
1 answer
381 views
Hi,

I'm using MVVM pattern on Diagram. I have a context menu set inside a style for targettype RadDiagramContainerShape. I want to pass the mouse position to the command as parameter (inside "NewShapeMenuItem" MenuItem).

How can I achieve this?

        <Style TargetType="telerik:RadDiagramContainerShape">            
            <Setter Property="ContextMenu">
                <Setter.Value>
                    <ContextMenu Name="ComponentContextMenu">
                        <MenuItem Name="NewMenuItem" Header="New">
                            <MenuItem Name="NewShapeMenuItem" Header="Shape" Command="{Binding AddCommand}" CommandParameter="{Binding ElementName=StateDiagram, Path=ActualHeight}" Icon="{StaticResource GoToShapeImage}"/>
                        </MenuItem>
                        <Separator/>
                        <MenuItem Header="Go to State" ItemsSource="{Binding ParentFacility.SelectedComponentViewModel.StateViewModels}"><!--IsEnabled="{Binding ParentFacility.Parent.IsOnline, Mode=TwoWay}"-->
                            <MenuItem.IsEnabled>
                                <MultiBinding Converter="{StaticResource ComponentToIsEnabledConverter}" Mode="TwoWay">
                                    <Binding Path="ParentFacility.Parent.IsOnline" Mode="TwoWay"/>
                                    <Binding Path="ParentFacility.SelectedComponentViewModel"/>
                                </MultiBinding>
                            </MenuItem.IsEnabled>
                            <MenuItem.ItemContainerStyle>
                                <Style TargetType="MenuItem">
                                    <Setter Property="Icon" Value="{StaticResource GoToStateImage}"></Setter>
                                    <Setter Property="Header" Value="{Binding Name}"></Setter>
                                    <Setter Property="Command" Value="{Binding ParentComponent.ParentFacility.GoToStateCommand}"></Setter>
                                    <Setter Property="CommandParameter" Value="{Binding}"></Setter>
                                </Style>
                            </MenuItem.ItemContainerStyle>
                        </MenuItem>
                    </ContextMenu>
                </Setter.Value>
            </Setter>
        </Style>

Pavel R. Pavlov
Telerik team
 answered on 18 Dec 2014
1 answer
107 views
Steps to reproduce:

1. Copy text from attach and paste it in the editor
2. Select a text and format it in red
3. Select other text and apply next formats: bold, italic, underline, strike
4. Select other text and highlight it
5. Go with cursor at the beginning of the text (before the bullet points) and press enter
6. Try to select any one from previously formatted texts

Aylin
Telerik team
 answered on 18 Dec 2014
1 answer
241 views
We're using the RadRichTextBox in a WPF application to create and store documents in a proprietary XML format.  We're using a formatter to convert them back to XAML for editing but we would also like to display requested documents on the web as PDF images.  While we can render a PDF version at the time the document is saved using RadRichTextBox, we would rather avoid the duplicate storage and render them as PDF when the document is requested from the site.

Is there a method for doing this type of conversion in a service?

Thanks in advance.
Petya
Telerik team
 answered on 18 Dec 2014
1 answer
161 views
Hello Telerik Team,

I have problems to display certain PDF Files. This time I don't even get a blank page as it was the case with the missing JBIG2Decode filter

Telerik user Georges already provides an example for a non working PDF File.

However I will just upload another one.

Thank you,
Joel

Note: I had to tamper with the file extension to surpass your "Allowed extensions" filter.
Deyan
Telerik team
 answered on 18 Dec 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?