Telerik Forums
UI for WPF Forum
0 answers
125 views

Hi

I have a GridView dinamically builded.  Columns are grouped and they can have an aggregate function. Some columns has different group but same aggregate function. 
I attached a screenshot.
There are 2 columns (min26 and min27), every column has AggregateMin as function. Caption of aggregatefunction is $"AggregateMin - {col.Header} - {col.ColumnGroupName} - ".
As you can see in the screenshot the two rows reports caption for every column.
I don't understand where is the problem.

This is the code that create the grid (it is quite complex but I think that is enough to understand the structure
		private void SetTableColumns(System.Collections.ObjectModel.ObservableCollection<RiassuntoElement> elementi
			, IEnumerable<LivelliSorgente> livelli = null)
		{
			RiassuntoSorgentiGrid.Columns.Clear();
			RiassuntoSorgentiGrid.ColumnGroups.Clear();
			if (elementi.Count() > 0)
			{
				GridViewDataColumn col;
				RiassuntoSorgentiGrid.ColumnGroups.Add(new GridViewColumnGroup()
				{
					Header = "",
					Name = GROUPNAME,
				});
				col = new GridViewDataColumn()
				{
					Header = Utility.LoadString(ResourcesKeys.SorgenteColumnHeader),
					ColumnGroupName = GROUPNAME,
					DataMemberBinding = new Binding("Sorgente.Name")
					{
						Mode = BindingMode.OneWay
					}
				};
				col.Footer = Utility.LoadString(ResourcesKeys.AggregatiHeader);
				col.FooterTextAlignment = TextAlignment.Center;
				RiassuntoSorgentiGrid.Columns.Add(col);
				RiassuntoSorgentiGrid.ColumnGroups.Add(new GridViewColumnGroup()
				{
					Header = Utility.LoadString(ResourcesKeys.GeneralTabHeader),
					Name = GENERALGROUPNAME,
				});
				if (LivelliRichiesti.Contains(LivelliSorgente.Durata))
				{
					col = new GridViewDataColumn()
					{
						Header = Utility.LoadString(ResourcesKeys.DurataComplessiva),
						ColumnGroupName = GENERALGROUPNAME,
						DataMemberBinding = new Binding("Sorgente.DurataComplessiva")
						{
							Mode = BindingMode.OneWay,
							Converter = new TimeSpanToStringOver24()
						}
					};
					SetAggregateFunction(LivelliSorgente.Durata, col);
					RiassuntoSorgentiGrid.Columns.Add(col);
				}

				RiassuntoSorgentiGrid.Columns.Add(new GridViewDataColumn()
				{
					Header = Utility.LoadString(ResourcesKeys.StartLabel),
					ColumnGroupName = GENERALGROUPNAME,
					IsSortable = true,
					DataFormatString = Application.Current.FindResource(ResourcesKeys.StringFormatTime).ToString(),
					DataMemberBinding = new Binding("Sorgente.IstanteIniziale")
					{
						Mode = BindingMode.OneWay
					}
				});

				RiassuntoSorgentiGrid.Columns.Add(new GridViewDataColumn()
				{
					Header = Utility.LoadString(ResourcesKeys.EndLabel),
					ColumnGroupName = GENERALGROUPNAME,
					DataFormatString = Application.Current.FindResource(ResourcesKeys.StringFormatTime).ToString(),
					DataMemberBinding = new Binding("Sorgente.IstanteFinale")
					{
						Mode = BindingMode.OneWay
					}
				});

				if (LivelliRichiesti.Contains(LivelliSorgente.Ripetizioni))
				{ 
					RiassuntoSorgentiGrid.Columns.Add(new GridViewDataColumn()
					{
						Header = Utility.LoadString(ResourcesKeys.RipetizioniSorgente),
						ColumnGroupName = GENERALGROUPNAME,
						DataFormatString = "D",
						DataMemberBinding = new Binding("Sorgente.Ripetizioni")
						{
							Mode = BindingMode.OneWay
						}
					});
				}
				for (int i = 0; i < elementi.First().Parametri.Count; i++)
				{
					SetSorgenteColumns(elementi, i, livelli);
				}
			}
		}

		int _numCol = 0;
		private void SetSorgenteColumns(System.Collections.ObjectModel.ObservableCollection<RiassuntoElement> elementi
			, int i, IEnumerable<LivelliSorgente> livelli)
		{
			try
			{

				if (livelli == null)
					livelli = LivelliRichiesti;
				var parametro = elementi.First().Parametri[i];
				string groupName = "Group" + parametro.Id;
				var group = new GridViewColumnGroup()
				{
					Header = parametro.Name,
					Name = groupName,
				};

				RiassuntoSorgentiGrid.ColumnGroups.Add(group); 
			
				foreach (var l in livelli)
				{
					if (l == LivelliSorgente.Durata || l == LivelliSorgente.Ripetizioni)
						continue;
					var attributes = l.GetType().GetMember(l.ToString())[0].GetCustomAttributes(typeof(TypeLivelliSorgenteAttribute), false);
					if (attributes.Length > 0 && attributes[0] is TypeLivelliSorgenteAttribute typeLivello)
					{
						var col = new GridViewDataColumn()
						{
							Name = l.ToString() + _numCol,
							Header = l.ToString() + _numCol++,
							ColumnGroupName = groupName,
							DataFormatString = typeLivello.TypeLivello switch
							{
								TypeLivelliSorgente.Date => Application.Current.FindResource(ResourcesKeys.StringFormatTime).ToString(),
								TypeLivelliSorgente.Double => "F1",
								TypeLivelliSorgente.Int => "D",
								TypeLivelliSorgente.TimeSpan => "",
								_ => "F1"
							},
							DataMemberBinding = new Binding($"Sorgente.LivelliSingoli[{parametro.Id}][{l}]")
							{
								Mode = BindingMode.OneWay,
								FallbackValue = "0",
								TargetNullValue = "0",
								Converter = (typeLivello.TypeLivello == TypeLivelliSorgente.TimeSpan)
									? new TimeSpanToStringOver24()
									: null
							}
						};
						SetAggregateFunction(l, col);
						
						RiassuntoSorgentiGrid.Columns.Add(col);
					}
				}
			}
			catch (Exception ex)
			{
				throw;
			}
		}

		private void SetAggregateFunction(LivelliSorgente l, GridViewDataColumn col)
		{
			col.AggregateFunctions.Clear();
			switch (l)
			{
				case LivelliSorgente.Leq:
					col.AggregateFunctions.Add(new AggregateLeqFunction()
					{
						Caption = $"AggregateLeq - {col.Header} - {col.ColumnGroupName} - ",
						FunctionName = "AggregateLeq",
						ResultFormatString = "{0:F1}",						
					});
					break;
				case LivelliSorgente.Max:
					col.AggregateFunctions.Add(new AggregateMaxFunction()
					{
						Caption = string.Empty,
						FunctionName = "AggregateMax",
						ResultFormatString = "{0:F1}"
					});
					break;
				case LivelliSorgente.TimeMax:
					col.AggregateFunctions.Add(new AggregateTimeMaxFunction
					{
						Caption = string.Empty,
						FunctionName = "AggregateTimeMax",
					});
					break;
				case LivelliSorgente.Min:
					col.AggregateFunctions.Add(new AggregateMinFunction()
					{
						Caption = $"AggregateMin - {col.Header} - {col.ColumnGroupName} - ",
						FunctionName = "AggregateMin",
						ResultFormatString = "{0:F1}"
					});
					break;
				case LivelliSorgente.TimeMin:
					col.AggregateFunctions.Add(new AggregateTimeMinFunction
					{
						Caption = string.Empty,
						FunctionName = "AggregateTimeMin",
					}) ;
					break;
				case LivelliSorgente.Ripetizioni:
					break;
				case LivelliSorgente.Durata:
					col.AggregateFunctions.Add(new AggregateDurataFunction()
					{
						Caption = string.Empty,
						FunctionName = "AggregateDurata"
					});
					break;
				case LivelliSorgente.Sel:
					break;
				case LivelliSorgente.LeqSpalmato:
					break;
				default:
					break;
			}
			col.FooterTextAlignment = TextAlignment.Center;
		}
Thank you
Luigi
Luigi
Top achievements
Rank 3
Bronze
Iron
Iron
 asked on 11 May 2022
1 answer
402 views

Hi,

My problem it's about Telerik.Windows.Controls.RichTextBoxUI. I'm on the process of upgrading a .NetFramework project to NET6, i've download the demo dlls for .NET6 and i'm setting up a Implicit Style, i've done everything this Link said, i've changed my Telerik UIs References to the NoXaml ones, i've merged the Xaml files and i've put the Office2019 themes on the project.

Now the problem is that RichTextBoxUI.xaml it's failing when compiling because can't find isStringNotEmptyToBoolConverter, and when i open the file, it's full of errors, saying it can find the assembly for Telerik.Windows.Controls.RichTextBoxUI. I'm guessing it's due to a missing DLL, but in \Binaries.NoXaml\WPF60 there's no dll for RichTextBoxUI, only RichTextBox.

Telerik.Windows.Documents.Xaml it's also failing and it's almost the same, failing references to other Documents. references that are not in the \Binaries.NoXaml\WPF60 folder.

It's there a place where i can find these dll? are they diferent for NET6 and i'm making a mistake with the setting of the Themes?

Thanks in advance.

Tanya
Telerik team
 answered on 11 May 2022
1 answer
158 views

Anchor tag with not text is by default not shown in HTML document. Such anchor tags are used for internal purpose.

<a href="/EORWeb/Download?/6971042495152-I.D card.pdf" target="_blank"/>

Importing Html document in Rad rich text box is working as expected, but if same document is converted to RTF first by using RtfFormatProvider or save html imported document as rtf; you will notice such anchor tags are visible in Richtextbox editor.

This behavior make consumer annoying, as he/she is expecting same behavior in standard html document. I checked import/export settings for both RtfFormatProvider and HtmlFormateProvider to stop such anchor tags.

For reference I am attaching sample html document, which contains such anchor tags, but supposed not to be appear in editor. and following RadRichtextbox behvior.

 

Correct behavior when importing html document

 

RFT document behavior. (Highlighted anchors need to be hidden)

 

Tanya
Telerik team
 answered on 11 May 2022
1 answer
100 views

I would like my PanelBarItem to not change the background color while I move my move over it.

This is what is happening and not desired

This is what is desired

Is there an easy and simple way to accomplish this?

Note: I am okay with the Header area changing color while the mouse is over that area. (area containing text A,B,C.).

I would like to avoid extracting and changing the entire template just for this one small change.

Thanks in advance.

Stenly
Telerik team
 answered on 09 May 2022
1 answer
106 views

There are often cases that raisePropertyChanged() Method is called outside UI main thread.

Is it okay to call it in this way, or should I use Dispathcer.Invoke()? 

Martin Ivanov
Telerik team
 answered on 09 May 2022
0 answers
339 views
I cannot install the RichTextBoxUI for Wpf (NoXAML or XAML) into a .NET Framework 4.7.x or 4.8 project

From the Private Telerik NuGet feed.

I see the other WPF Controls... but not RichTextBoxUI

Nick
Top achievements
Rank 2
 asked on 09 May 2022
0 answers
106 views

I have a RadGridView in my application and did not explicitly set the style for it. It works well in normal contrast mode but when turn on the Aquatic high contrast mode in Windows 11, the contrast between the text and background on the header becomes minimal like  below.

 

I tried changing the style like below but the text will stay at the defined color regardless of the contrast mode.

<Style TargetType="telerik:GridViewHeaderCell" BasedOn="{StaticResource GridViewHeaderCellStyle}">
                <Setter Property="Foreground" Value="Red"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
 </Style>

 

boon
Top achievements
Rank 1
 updated question on 06 May 2022
1 answer
117 views

Hi Team,

I have two questions, I am using RadNumericUpDownButton for getting time input. So I have used two separate numeric button to get hours and minutes.

  • I want to show the hours and minutes in two numeric digits like 01, 02, 08. Any solution to achieve this?
  • And I want get AM and PM with same RadNumericUpDownButton. Is there any way to do this?

Stenly
Telerik team
 answered on 06 May 2022
1 answer
103 views

Is it possible to let the drop down content open with bottom right aligned placement? Currently, when setting the drop down placement to "Bottom", it opens left aligned relative to the the split button.

Please see attachment for how it should look

 

Stenly
Telerik team
 answered on 05 May 2022
0 answers
136 views

I have a GridViewDataColumn that binds to a complex model (Custom class with a few properties and a ToString method)

The GridViewDataColumn also has a CustomGridFilter which is able to filter the column and has it's own popup. 

But .. now the users also want to Order by this column - but nothing happens when clicking on the Column Header. 

What am i missing ?

<telerik:GridViewDataColumn Width="100"
		DataMemberBinding="{Binding YearRange}"
		Header="Ã…rgang">
	<telerik:GridViewDataColumn.FilteringControl>
		<local:CustomGridFilter Aargang="{Binding ElementName=root, Path=VintageYear, Mode=TwoWay}" />
	</telerik:GridViewDataColumn.FilteringControl>
</telerik:GridViewDataColumn>
public class YearRange : IEquatable<int>
{
    public int FromYear { get; set; }

    public int ToYear { get; set; }

    public int Year { get; set; }

    public override string ToString()
    {
        if (FromYear == ToYear)
            return FromYear.ToString();

        return FromYear + "-" + ToYear;
    }

  #region Equals, GetHashCode

  #region Comparison operators override
}

public partial class CustomGridFilter : UserControl, IFilteringControl, INotifyPropertyChanged
{
    private GridViewBoundColumnBase column;
    private CompositeFilterDescriptor compositeFilter;
    private FilterDescriptor rangeFilter;

    #region INotifyPropertyChanged

    public void OnPropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));

    public event PropertyChangedEventHandler PropertyChanged;

    #endregion

    #region IsActive DependencyProperty 
    public bool IsActive
    {
        get { return (bool)GetValue(IsActiveProperty); }
        set { SetValue(IsActiveProperty, value); }
    }

    public static readonly DependencyProperty IsActiveProperty =
        DependencyProperty.Register(
            "IsActive",
            typeof(bool),
            typeof(CustomGridFilter),
            new PropertyMetadata(false));
    #endregion

    #region Aargang DependencyProperty 

    public int? Aargang
    {
        get { return (int?)GetValue(AargangProperty); }
        set { SetValue(AargangProperty, value); }
    }

    public static readonly DependencyProperty AargangProperty =
        DependencyProperty.Register(
            "Aargang",
            typeof(int?),
            typeof(CustomGridFilter),
            new PropertyMetadata(
                null,
                (sender, evt) => { ((CustomGridFilter)sender).OnPropertyChanged("Aargang"); }
            )
        );

    #endregion

    public CustomGridFilter()
    {
        InitializeComponent();

        DataContext = this;

        PropertyChanged += CustomGridFilter_PropertyChanged;
    }

    private void CustomGridFilter_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        if (e.PropertyName == "Aargang" && Aargang>1900 && Aargang<2100)
        {
            OnFilter(null, null);
        }
    }

    public void Prepare(Telerik.Windows.Controls.GridViewColumn column)
    {
        this.column = column as GridViewBoundColumnBase;

        if (this.column == null)
        {
            return;
        }

        if (compositeFilter == null)
        {
            CreateFilters();
        }
    }

    private void CreateFilters()
    {
        string dataMember = column.DataMemberBinding.Path.Path;

        compositeFilter = new CompositeFilterDescriptor();

        rangeFilter = new FilterDescriptor(dataMember, FilterOperator.IsEqualTo, null);

        compositeFilter.FilterDescriptors.Add(rangeFilter);
    }

    private void OnFilter(object sender, RoutedEventArgs e)
    {
        rangeFilter.Value = new YearRange { Year = Aargang ?? 0 };

        if (!column.DataControl.FilterDescriptors.Contains(compositeFilter))
        {
            column.DataControl.FilterDescriptors.Add(compositeFilter);
        }

        IsActive = true;

        var popup = this.ParentOfType<System.Windows.Controls.Primitives.Popup>();
        if (popup != null)
        {
            popup.IsOpen = false;
        }
    }

    private void OnClear(object sender, RoutedEventArgs e)
    {
        if (column.DataControl.FilterDescriptors.Contains(compositeFilter))
        {
            column.DataControl.FilterDescriptors.Remove(compositeFilter);
        }

        Aargang = 0;

        IsActive = false;

        var popup = this.ParentOfType<System.Windows.Controls.Primitives.Popup>();
        if (popup != null)
        {
            popup.IsOpen = false;
        }
    }

}

 

 

 

Martin
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 05 May 2022
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?