Telerik Forums
UI for WPF Forum
1 answer
426 views

When we print any large (10-500 pages) document  using WPF PdfViewer the UI becomes unresponsive. For the document with 100 pages it might take minutes. Are there any solutions for PdfViewer that improve User Experience printing large documents? To be more specific, is there a way to:

Show the progress bar with number of pages completed and left or % done with "Cancel" printing job button

OR

any other solution that would help to implement asynchronous printing?

Deyan
Telerik team
 answered on 14 Jul 2016
1 answer
141 views

Hi,

While for all major UI apps my organization is using RagGridView, for a side project that crept up a few months back, we need just the RadGridView. The app in question already has metro style implemented using a third party UI framework. We need just the radgridview in this app and since the app has a metro looking UI, we want the radgridview to sport the metro look.

Can someone please point out how to use achieve this without affecting the entire application's look and feel (I mean thememanager, affects the  entire application)?

regards,

Sid

Stefan Nenchev
Telerik team
 answered on 14 Jul 2016
1 answer
381 views

I have a cellstyleselector

public class MyStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            return MyStyle;
        }
        public Style MyStyle { get; set; }
    }

I have a grid called DashboardGrid where I add columns in the code behind as they are dependent on columns which the user wants to see. I do this in the following code.

 

foreach (var deliverable in viewModel.Profile.Deliverables)
{

                GridViewDataColumn myColumn = new GridViewDataColumn();
                myColumn.DataMemberBinding = new Binding(deliverable.Path + ".My")
                {
                    Converter = dateToWeekNumberConverter //Using a converter
                };
                myColumn.Header = "Col1";
                myColumn.UniqueName = deliverable.Path + ".My";
                Style style = new Style(typeof(GridViewCell));
                Setter setter = new Setter(GridViewCell.BackgroundProperty, new Binding(deliverable.Path + ".MyBackgroundBrush"));
                style.Setters.Add(setter);
                DeliverableStyleSelector deliverableStyle = new DeliverableStyleSelector();
                deliverableStyle.DeliverableStyle = style;
                myColumn.CellStyleSelector = deliverableStyle;
                this.DashBoardGrid.Columns.Add(myColumn);

 

                GridViewDataColumn myColumn2 = new GridViewDataColumn();
                myColumn2.DataMemberBinding = new Binding(deliverable.Path + ".My2")
                {
                    Converter = dateToWeekNumberConverter //Using a converter
                };
                myColumn2.Header = "Col1";
                myColumn2.UniqueName = deliverable.Path + ".My2";
                Style style = new Style(typeof(GridViewCell));
                Setter setter = new Setter(GridViewCell.BackgroundProperty, new Binding(deliverable.Path + ".MyBackgroundBrush2"));
                style.Setters.Add(setter);
                DeliverableStyleSelector deliverableStyle = new DeliverableStyleSelector();
                deliverableStyle.DeliverableStyle = style;
                myColumn2.CellStyleSelector = deliverableStyle;
                this.DashBoardGrid.Columns.Add(myColumn2);

}

When 'My' > 'My2' then the MyBackgroundBrush is changed to Brushes.GreenYellow. The code works fine until I scroll through the grid. Then the cell styles are gone. PFA the screenshots. Please help me.

 

Note:  I can't add the styles in the xaml as I dont know how many deliverables are going to come. It can range from 1 deliverable to 100 and their setter is dependent on the MyBackgroundBrush and binding, deliverable.Path whose values again will be different as the deliverables.

 

Stefan Nenchev
Telerik team
 answered on 14 Jul 2016
6 answers
229 views
I have defined a simple grid as follows:

<Grid Margin="20">
    <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="30" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <TextBlock Grid.Column="0" />
    <Border BorderBrush="LightGray" BorderThickness="1" Grid.Row="1" />
    <telerik:RadGridView x:Name="gridTradePackages"
                         Grid.Row="2" BorderThickness="1,0,1,1"
                         AutoGenerateColumns="True">
 
    </telerik:RadGridView>
</Grid>

I'm then simply binding an observablecollection to the grid. 

The issue I have is why I have odd spacing of the filter selector in the column header and why the filtered list (when clicked) is centered? I have removed every property of the grid right down to auto generating columns but am lost as to why this should occur. I haver attached a screen shot that shows the behaviour.
Christian
Top achievements
Rank 1
 answered on 14 Jul 2016
24 answers
176 views

Hi! Our colleague Eugene writes periodically in your forum. We use RadTreeListView in our project. As datasource for RadTreeListView we use an ObservableCollection containing hierarchical data. This hierarchical data are displayed in RadTreeListView perfectly well. Please see "Picture.PNG" file attached. But we can't edit information in any cell in second column. When the user does doubleclick on a cell and this cell is switched in edit mode then the data in the cell disappears and the user can't print the new data there. Please see the cell image in edit mode in "Picture2.PNG" file attached. Below is XAML concerning RadTreeListView in our application:

<telerik:RadTreeListView Grid.Row="2" Grid.Column="0" AutoGenerateColumns="False" AutoExpandItems="True" IsSynchronizedWithCurrentItem="True"
                                     ItemsSource="{Binding ProfileTreeRoot.ChildProfileElenents}">
                <telerik:RadTreeListView.ChildTableDefinitions>
                    <telerik:TreeListViewTableDefinition ItemsSource="{Binding ChildProfileElenents}"/>
                </telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:RadTreeListView.Columns>
                    <telerik:GridViewDataColumn IsReadOnly="True" DataMemberBinding="{Binding Name}" Header="Наименование">
                        <telerik:GridViewDataColumn.CellStyle>
                            <Style TargetType="{x:Type telerik:GridViewCell}">
                                <Setter Property="FontWeight" Value="SemiBold"/>
                            </Style>
                        </telerik:GridViewDataColumn.CellStyle>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding CurrentValue}" Header="Текущее значение"/>
                </telerik:RadTreeListView.Columns>
            </telerik:RadTreeListView>

Where 'ProfileTreeRoot.ChildProfileElements' is ObservableCollection instance. 'ProfileTreeRoot' itself is the instance of Group class where ObservableCollection is. Below is Group class definition. You can see 'ChildProfileElements' ObservableCollection definition there.

public class Group : ProfileElementType
{
    #region Fields
    private string name;
    private string description;
    private ObservableCollection<ProfileElementType> _childProfileElenents;
    private Group parent;
    #endregion
 
    #region Constructors
    public Group()
    {
       this.ElementType = this.GetType();
       this.ElementTypeName = this.ElementType.Name;
       this.Name = "Group 1";
       this.ChildProfileElenents = new ObservableCollection<ProfileElementType>();
    }
    #endregion
 
    #region Properties
    [Display(Description = "The Name of this Group.", Name = "The Name")]
    public string Name
    {
        get { return this.name; }
        set { this.SetProperty(ref this.name, value); }
    }
    [Display(Description = "The Brief Description of this Group", Name = "The Description")]
    public string Description
    {
        get { return this.description; }
        set { this.SetProperty(ref this.description, value); }
    }
    /// <summary>
    /// The collection of elements which are the children elements of this group.
    /// These elements can be of Group class instances or Register class instances
    /// </summary>
    [Browsable(false)]
    public ObservableCollection<ProfileElementType> ChildProfileElenents
    {
        get { return this._childProfileElenents; }
        set { this.childProfileElenents = value; }
    }
    /// <summary>
    /// Parent group whose ChildProfileElenents collection comprises this Group instance.
    /// </summary>
    [Browsable(false)]
    public Group Parent
    {
        get { return this.parent; }
        set { this.parent = value; }
    }
    #endregion
}

Group class reprecents group containing some registers and some other groups. As you can see the ObservableCollection in Group is defined as the follow:

private ObservableCollection<ProfileElementType> _childProfileElenents;

Below the definition of ProfileElementType class and Register class. First 'Register' class is shown:

public class Register : ProfileElementType
{
   #region Fields
   private int number;
   private string name;
   private string description;
   private string currentValue;
   private string defaultValue;
   private string minimalValue;
   private string maximalValue;
   private string dataTypeName;
   private RegisterDataAccess accessToData;
   private Group parent;
   #endregion
 
   #region Constructors
   public Register()
   {
       this.ElementType = this.GetType();
       this.ElementTypeName = this.ElementType.Name;
       this.Name = "REgister 1";
       this.AccessToData = RegisterDataAccess.Read_Write;
   }
   #endregion
 
   #region Properties
   [Display(Description = "Register Address.", Name = "The Address", GroupName = "Common Information")]
   public int Number
   {
       get { return this.number; }
       set { this.SetProperty(ref this.number, value); }
   }
   [Display(Description = "Register Name.", Name = "The Name", GroupName = "Common Information")]
   public string Name
   {
      get { return this.name; }
      set { this.SetProperty(ref this.name, value); }
   }
   [Display(Description = "Breif description.", Name = "The Description", GroupName = "Common Information")]
   public string Description
   {
      get { return this.description; }
      set { this.SetProperty(ref this.description, value); }
   }
   [Display(Description = "Register current value.", Name = "Current Value", GroupName = "Data")]
   public string CurrentValue
   {
      get { return this.currentValue; }
      set { this.SetProperty(ref this.currentValue, value); }
   }
   [Display(Description = "Register default value.", Name = "Default value", GroupName = "Data")]
   public string DefaultValue
   {
      get { return this.defaultValue; }
      set { this.SetProperty(ref this.defaultValue, value); }
   }
   [Display(Description = "Register Minimal Value.", Name = "Minimal Value", GroupName = "Data")]
   public string MinimalValue
   {
      get { return this.minimalValue; }
      set { this.SetProperty(ref this.minimalValue, value); }
   }
   [Display(Description = "Register Maximal Value.", Name = "Maximal Value", GroupName = "Data")]
   public string MaximalValue
   {
      get { return this.maximalValue; }
      set { this.SetProperty(ref this.maximalValue, value); }
   }
   [Display(Description = "Register Data Type.", Name = "Data Type", GroupName = "Data")]
   public string DataTypeName
   {
      get { return this.dataTypeName; }
      set { this.SetProperty(ref this.dataTypeName, value); }
   }
   [Display(Description = "Access to Register Data.", Name = "Data Access", GroupName = "Data")]
   public RegisterDataAccess AccessToData
   {
      get { return this.accessToData; }
      set { this.SetProperty(ref this.accessToData, value); }
   }
   /// <summary>
   /// Parent group whose ChildProfileElenents collection comprises this Register instance.
   /// </summary>
   [Browsable(false)]
   public Group Parent
   {
      get { return this.parent; }
      set { this.parent = value; }
   }
   #endregion
}

And here is ProfileElementType class definition:

public class ProfileElementType : BindableBase, IProfileElementType
{
    #region Fields
    private string _elementTypeName;
    #endregion
 
    #region Properties
    [Browsable(false)]
    public string ElementTypeName
    {
       get { return this._elementTypeName; }
       set { this._elementTypeName = value; }
    }
    #endregion
 
    #region IProfileElementType Implementation
    private Type _elementType;
    [Browsable(false)]
    public Type ElementType
    {
       get { return this._elementType; }
       set { this._elementType = value; }
    }
    #endregion
}

Can we (in our case) edit cells in RadTreeListViev? After all, if their content is displayed perfectly, then why can not edit it? We really need to get a cell in RadTreeListViev edited. Please help us.

Dilyan Traykov
Telerik team
 answered on 14 Jul 2016
12 answers
2.3K+ views

I write C# WPF MVVM Prism 6 multimodule application in MS VS 2015. In my application I use your Telerik for WPF library that was updated in May 2016. In one of Prism modules I try to change one of the views from PrismUserControl(WPF) to telerik:RadWindow (as you have written in your instruction on: http://docs.telerik.com/devtools/wpf/controls/radwindow/how-to/use-radwindow-as-user-control). But when I create RadWindow according to abovementioned instruction then the following error has place: "XamlObjectWriterException: Setting of "System.Windows.ResourceDictionary.Source" property throws an exception".

StackTrace
 
   in MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
   in MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.SetValue(Object obj, XamlMember property, Object value)
   in System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(ObjectWriterContext ctx, XamlMember prop, Object value, Boolean onParent)
   in System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx)
   in System.Xaml.XamlObjectWriter.Logic_AssignProvidedValue(ObjectWriterContext ctx)
   in System.Xaml.XamlObjectWriter.WriteEndMember()
   in System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   in System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
   in System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter)
   in System.Windows.SystemResources.ResourceDictionaries.LoadDictionary(Assembly assembly, String assemblyName, String resourceName, Boolean isTraceEnabled)
   in System.Windows.SystemResources.ResourceDictionaries.LoadGenericDictionary(Boolean isTraceEnabled)
   in System.Windows.SystemResources.FindDictionaryResource(Object key, Type typeKey, ResourceKey resourceKey, Boolean isTraceEnabled, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
   in System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
   in System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce)
   in System.Windows.FrameworkElement.UpdateThemeStyleProperty()
   in System.Windows.FrameworkElement.OnInitialized(EventArgs e)
   in Telerik.Windows.Controls.RadWindow.OnInitialized(EventArgs e)
   in System.Windows.FrameworkElement.TryFireInitialized()
   in System.Windows.FrameworkElement.EndInit()
 
InnerException Cannot locate resource 'themes\genericvista.xaml'
   IOException: Cannot locate resource 'themes\genericvista.xaml'
 
   StackTrace
 
   in MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
   in System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
   in System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
   in System.IO.Packaging.PackWebResponse.GetResponseStream()
   in System.IO.Packaging.PackWebResponse.get_ContentType()
   in MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response)
   in MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest request, ContentType& contentType)
   in System.Windows.ResourceDictionary.set_Source(Uri value)
   in System.Windows.Baml2006.WpfSharedBamlSchemaContext.<>c.<Create_BamlProperty_ResourceDictionary_Source>b__342_0(Object target, Object value)
   in System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
   in MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
   in MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
.InnerException: No

Moreover. If I add in XAML, for example, telerik:RadButton or telerik:RadTreView then (in design-time)  "Cannot locate resource 'themes\genericvista.xaml' error occurs.

Below I dusplay contents of App.XAML file from Shell project of my application solution:

<Application x:Class="FlowmeterConfigurator.App"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:local="clr-namespace:FlowmeterConfigurator"
             xmlns:views="clr-namespace:FlowmeterConfigurator.Views">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/System.Windows.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2013;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="views:Shell" BasedOn="{StaticResource RadWindowStyle}" />
        </ResourceDictionary>
    </Application.Resources>
</Application>

What the reason of "Cannot locate resource 'themes\genericvista.xaml' error ? How to eliminate it? Please help.

 

Chris
Top achievements
Rank 1
 answered on 13 Jul 2016
2 answers
145 views

Hello,

I'm having the following issue with the Serialization process in the diagram:

When I save the first time, it works great. (I can reload the layout several times and it works perfectly: my items go back to their saved positions)

However, if I saveLayout, then LoadLayout, the next time I'm going to call SaveLayout will fail because node is null in the GetNodeUniqueId override.

Any idea what could cause this? Thanks!

public class NodeViewModel : NodeViewModelBase
{
 
}
 
public class DiagramViewModel : SerializableGraphSourceBase<NodeViewModel, LinkViewModel>
{
 
public override string GetNodeUniqueId(NodeViewModel node)
       {
           if (node == null)
               return string.Empty; // Should not happen (but happens on a saveLayout after a LoadLayout)
           return node.ID;
       }
 
public override NodeViewModel DeserializeNode(IShape shape, SerializationInfo info)
        {
            NodeViewModel nodeViewModel = InternalItems.FirstOrDefault(p => p.DialogInfo.Tag == info["NodeUniqueIdKey"].ToString());
            if (nodeViewModel == null)
                return null;
 
            string position = info["Position"].ToString();
            string[] arr = position.Split(';');
            nodeViewModel.Position = new Point(float.Parse(arr[0], CultureInfo.InvariantCulture), float.Parse(arr[1], CultureInfo.InvariantCulture));
            return nodeViewModel;
        }
}

Martin Ivanov
Telerik team
 answered on 13 Jul 2016
3 answers
548 views

Hi,

I am using the richtextbox with theming having a dark background. I now would like to permanently set the textforecolor to a light color (like white, depending on the selected dark theme) so that
1.) regular text is displayed with a light forecolor
2.) pasted plain text  is inserted and displayed with a light forecolor
3.) richtext forecolor is changed to a light forecolor
4.) when using the color picker the 'automatic' color is the light forecolor that has been set recently.

what I have so for:

<DockPanel LastChildFill="True">
    <telerik:RadRichTextBoxStatusBar DockPanel.Dock="Bottom" AssociatedRichTextBox="{Binding ElementName=richTextBox}" />
    <telerik:RadRichTextBox x:Name="richTextBox" DockPanel.Dock="Top" 
        Background="{Binding ''}"
        DocumentInheritsDefaultStyleSettings="True"
        Foreground="White"
        FontSize="12"
        IsContextMenuEnabled="True"
        IsSelectionMiniToolBarEnabled="True"
        IsSpellCheckingEnabled="False"
        AcceptsReturn="True"
        AcceptsTab="True" CommandExecuting="richTextBox_CommandExecuting" >
        <telerik:RadRichTextBox.Resources>
            <Style TargetType="{x:Type telerik:DocumentWebLayoutPresenter}">
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style TargetType="{x:Type telerik:DocumentPrintLayoutPresenter}">
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <!--<Style TargetType="telerik:RadRichTextBox">
                <Setter Property="Background" Value="{DynamicResource ContainerBackgroundBrush}" />
            </Style>-->
        </telerik:RadRichTextBox.Resources>
    </telerik:RadRichTextBox>
</DockPanel>

public bool PasteAsPlaneText { get; set; } = true;
 
private void richTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
    if (e.Command is PasteCommand)
    {
        if (PasteAsPlaneText)
        {
            e.Cancel = true;
            this.richTextBox.Insert(Clipboard.GetText());
        }
    }
 }

Until now I couldn't find a way to achieve this. How would I have to proceed to get this szenario implemented? Any example/solution?

Thanks in advance.

Todor
Telerik team
 answered on 13 Jul 2016
0 answers
118 views

Hello, 

Can anyone please explain to me how to resize the row height whenever the RadGridView height is changed at runtime?

Thanks in advance.

awt
Top achievements
Rank 1
 asked on 13 Jul 2016
2 answers
483 views
How would I go about adding a RadContextMenu to a RadGridView programmatically? I am building the RadGridView completely in code at runtime, and don't have a predefined XAML component.

The RadGridView only seems to have a ContextMenu that can be set, but I can't hook a RadContextMenu to the ContextMenu property.

Any advice? I need this so I can have the row that is right-clicked selected, and I can look at the current cell so that I can have specific menu items added to the context menu.
Oscar
Top achievements
Rank 1
 answered on 12 Jul 2016
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?