Telerik Forums
UI for WPF Forum
1 answer
199 views
Hi,

Our application have predefined document variables and we put these variables inside documents. Some of the variables contains singleline text but some of them have multiline text. For multiline text we add \v vertical tab for line break. When we add line break RadRichTextBox UI shows as we expected.
For example we added a text "Progress Telerik\vVertical Tab Test Second Line\vThird Line" and RadRichTextBox UI shows as

Progress Telerik
Vertical Tab Test Second Line
Third Line

But when we exported these xaml file as xaml format, final xaml file is not the same as shown in RadRichTextBox UI. The last line repeated for all the lines. Exported xaml file repeates "Third Line" line as shown below.


<t:Paragraph TextAlignment="Center">
  <t:FieldRangeStart AnnotationID="1">
    <t:DocumentVariableField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" VariableName="D_ALICI" />
  </t:FieldRangeStart>
  <t:Span BaselineAlignment="Baseline" FontFamily="Times New Roman" FontSize="16" FontStyle="Normal" FontWeight="Bold" ForeColor="#FF000000" HighlightColor="#00FFFFFF" Strikethrough="False" Text="Third Line" ThemeForeColorShade="" ThemeForeColorTint="" ThemeUnderlineColorShade="" ThemeUnderlineColorTint="" UnderlineColor="#FF000000" UnderlineDecoration="None" />
  <t:Break BreakType="LineBreak" Text="¬" />
  <t:Span BaselineAlignment="Baseline" FontFamily="Times New Roman" FontSize="16" FontStyle="Normal" FontWeight="Bold" ForeColor="#FF000000" HighlightColor="#00FFFFFF" Strikethrough="False" Text="Third Line" ThemeForeColorShade="" ThemeForeColorTint="" ThemeUnderlineColorShade="" ThemeUnderlineColorTint="" UnderlineColor="#FF000000" UnderlineDecoration="None" />
  <t:Break BreakType="LineBreak" Text="¬" />
  <t:Span BaselineAlignment="Baseline" FontFamily="Times New Roman" FontSize="16" FontStyle="Normal" FontWeight="Bold" ForeColor="#FF000000" HighlightColor="#00FFFFFF" Strikethrough="False" Text="Third Line" ThemeForeColorShade="" ThemeForeColorTint="" ThemeUnderlineColorShade="" ThemeUnderlineColorTint="" UnderlineColor="#FF000000" UnderlineDecoration="None" />
  <t:FieldRangeEnd AnnotationID="1" />
</t:Paragraph>


How can we solve this problem?

You can download sample application and final xaml file from  https://we.tl/t-KYQh8XpGfF

Martin
Telerik team
 answered on 16 Sep 2020
3 answers
1.1K+ views
Hello,

I am working on an MVVM application.I have in view a ListBox which is bound to an ObservableDictionary in VM as follows:

C# VM:

private ObservableDictionary<string, bool> mCategories;
public ObservableDictionary<string, bool> Categories
{
get { return mCategories; }
set { mCategories = value; FirePropertyChanged("Categories"); }
}

Categories = new ObservableDictionary<string, bool>()
{
{ "Allgemein", true},
{ "Dampf", false},
{ "Fernwärme", false},
{ "Prozessabhängig", false},
{ "Stromverbrauch", false}
};



XAML VIEW:

<telerik:RadListBox ItemsSource="{Binding Categories}">
    <telerik:RadListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding Value, Mode=TwoWay}"/>
                <TextBlock Text="{Binding Key, Mode=OneWay}"/>
            </StackPanel>
        </DataTemplate>
    </telerik:RadListBox.ItemTemplate>
</telerik:RadListBox>



I have the following problem: Binding seems not to work in the direction View to VM, that when I check a Checkbox the Value of the corresponding dictionary element will not be set to true, while it works in the other direction (VM to View) that when I set the Value of a dictionary elemnt in C# code (VM) the CheckBx is checked in View.

Any suggestion?

Thanks
Dilyan Traykov
Telerik team
 answered on 15 Sep 2020
5 answers
294 views

Hi,

I'm using  grid.SelectedItems.Add(row); in a loop to select rows on a grid. However sometimes I need to select 10,000+ rows and this can take over 15 seconds. I have tired .AddRange() but that takes the same amount of time. 

Is there a faster way to select items, especially with a very large number of rows?

Thanks,

Richard

Dilyan Traykov
Telerik team
 answered on 15 Sep 2020
7 answers
391 views

Hello,

I don't get any rows displayed when filtering with popup mode, grouping with drag&drop and sorting either by clicking on the column header or programatically.

And I get all my rows back when clearing filter/grouping/sorting either directly on the UI or programatically. Could you please help me?

 

Designer.xaml

<telerik:RadGridView x:Name="AttributesTable" ItemsSource="{Binding Path=Items}" RowDetailsVisibilityMode="Collapsed"
                             ScrollViewer.CanContentScroll="False" AutoGenerateColumns="False" CanUserSortColumns="True"
                             Sorting="AttributesTable_Sorting" PreparedCellForEdit="AttributesTable_PreparedCellForEdit"
                             CellEditEnded="AttributesTable_CellEditEnded"
                             FilteringMode="Popup" IsFilteringAllowed="True" MouseLeftButtonDown="AttributesTable_MouseLeftButtonDown"
                             FieldFilterEditorCreated="OnRadGridViewFieldFilterEditorCreated">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <Button Style="{StaticResource NoChromeButton}" Command="{base:XamlRoot Path=DataContext.Navigate}" CommandParameter="{Binding}">
                                <Image Source="/STTAR;component/Resources/Object_Globe_16xLG.png" ToolTip="{base:ResX ResKey=CenterMapToolTip}"/>
                            </Button>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

 

Code.cs

columns = (this.DataContext as AttributesTableViewModel)?.Columns;
items = (this.DataContext as AttributesTableViewModel)?.Items;
DynAdapter = (this.DataContext as AttributesTableViewModel)?.DynAdapter;

if (columns.Count == 0)
{
    var temp = AttributesTable.Columns[0];
    AttributesTable.Columns.Clear();
    AttributesTable.Columns.Add(temp);
    return;
}
 
var alreadyInsertedColsNames = (from col in (AttributesTable.Columns as ObservableCollection<GridViewColumn>).Where(col => col.DisplayIndex != 0) select col.Header as string).ToList();
var colsNames = (from col in columns select col.DisplayName).ToList();
var notInsertedColsNames = colsNames.Except(alreadyInsertedColsNames).ToList();
var toRemoveColsNames = alreadyInsertedColsNames.Except(colsNames).ToList();
 
if (notInsertedColsNames.Count > 0)
    foreach (string colName in notInsertedColsNames)
    {
        FeatureAttribute selectedCol = columns.Where(col => col.DisplayName == colName).FirstOrDefault();
        var gridViewColumn = new GridViewDataColumn();
 
        switch (selectedCol.Name)
        {
            case FeatureAttributes.Cost:
                string costUnit = String.Format(" ({0})", DynAdapter.Project.Settings.CurrencyCode);
                gridViewColumn.Header = selectedCol.DisplayName + costUnit;
                break;
            case FeatureAttributes.Length:
                string lengthUnit = " (m)";
                gridViewColumn.Header = selectedCol.DisplayName + lengthUnit;
                break;
            case FeatureAttributes.Id:
            case FeatureAttributes.Source:
            case FeatureAttributes.Support:
                gridViewColumn.IsReadOnly = true;
                gridViewColumn.Header = selectedCol.DisplayName;
                break;
            default:
                gridViewColumn.Header = selectedCol.DisplayName;
                break;
        }
 

                       // GetBindingStringForAttribute returns ".[propertyName]"

        gridViewColumn.DataMemberBinding = new Binding(GetBindingStringForAttribute(selectedCol));
        gridViewColumn.FilterMemberPath = GetBindingStringForAttribute(selectedCol);
        gridViewColumn.FilterMemberType = selectedCol.DataType;
        gridViewColumn.DataType = selectedCol.DataType;
        gridViewColumn.ShowDistinctFilters = false;
        gridViewColumn.CellTemplateSelector = (DataTemplateSelector)GridContainer.Resources["CellTemplateSelector"];
        gridViewColumn.CellEditTemplateSelector = (DataTemplateSelector)GridContainer.Resources["CellEditTemplateSelector"];
        AttributesTable.Columns.Add(gridViewColumn);
    }
 
    foreach (string toRem in toRemoveColsNames)
    {
        var colToRemove = (AttributesTable.Columns as ObservableCollection<GridViewColumn>)
        .FirstOrDefault(col => col.Header == toRem);
        if (AttributesTable.Columns.Contains(colToRemove))
            AttributesTable.Columns.Remove(colToRemove);
    }
Vladimir Stoyanov
Telerik team
 answered on 15 Sep 2020
3 answers
132 views

We have our custom class for saving the grid configuration, i.e sorting/grouping/resizing/column order and we add Unloaded event on our grid like so:

            public static void Persistence(/*params here*/)

                  grid.Unloaded += (sender, args) =>
                  {
                         var data = GenerateGridSettings(grid, whatToSave, column => column.UniqueName);
                         if (data != null)
                              // save settings goes here
                   };

             }

Although this looks good and I as developer and the QA team do not get error messages, our customers get error messages, specifically "Object was not set to an instance of an object". The error output is this:

    2020/09/03 09:36:17.259 29 - 17832 Client.Global.Dispatcher FATAL Object reference not set to an instance of an object.
       at Controls.RadGridSupport.<>c.<Persistence>b__26_4(GridViewColumn column)
       at Controls.RadGridSupport.GenerateGridSettings(RadGridView rgv, RadGridSettingSelection whatToSave, Func`2 mapColumnToName)
       at Controls.RadGridSupport.<>c__DisplayClass26_0.<Persistence>b__1(Object sender, RoutedEventArgs args)
       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.RaiseEvent(RoutedEventArgs e)
       at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
       at System.Windows.BroadcastEventHelper.BroadcastUnloadedEvent(Object root)
       at MS.Internal.LoadedOrUnloadedOperation.DoWork()
       at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

 

As if the column in the lambda expression "column => column.UniqueName" gets deleted at some point before unloaded event.

 

Is this possible? Can the column be deleted before the unloaded event?


Dilyan Traykov
Telerik team
 answered on 15 Sep 2020
2 answers
567 views

I have a nested Dictionary with 5 levels.

I would like to show it in the TreeView but I only get the first layer.

<telerik:RadTreeView x:Name="myTreeView"
                             MinWidth="200px"
                             ItemsSource="{Binding Areas}"
                             ItemTemplate="{StaticResource BuildingHDT}"
                             ItemContainerStyle="{StaticResource ItemContainerStyle}"
                             MaxHeight="{Binding ElementName=host, Path=ActualHeight}"
                             Grid.IsSharedSizeScope="True"
                             HorizontalContentAlignment="Stretch"
                             IsVirtualizing="True"
                             TextSearch.TextPath="Value.Name"
                             extension:ContextMenuBehavior.ContextMenu="{Binding ElementName=TreeContextMenu}">

            <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="TreeContextMenu"/>
            </telerik:RadContextMenu.ContextMenu>

            <telerik:EventToCommandBehavior.EventBindings>
                <telerik:EventBinding Command="{Binding OpenSelectedItem}"
                                      EventName="MouseLeftButtonDown"
                                      RaiseOnHandledEvents="True"
                                      PassEventArgsToCommand="True" />
            </telerik:EventToCommandBehavior.EventBindings>

        </telerik:RadTreeView>

 

<HierarchicalDataTemplate x:Key="QualifierHDT"
                                  DataType="{x:Type models:Qualifier}"
                                  ItemsSource="{Binding Qualifier}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Value.Name}" />
                <TextBlock Text="{Binding Value.AnnotationCount}" Margin="5 0 0 0" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="ComponentHDT"
                                  DataType="{x:Type models:Component}"
                                  ItemsSource="{Binding Component}"
                                  ItemTemplate="{StaticResource QualifierHDT}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Key}" />
                <TextBlock Text="{Binding Value.AnnotationCount}" Margin="5 0 0 0" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="SystemCollectionHDT"
                                  DataType="{x:Type models:SystemCollection}"
                                  ItemsSource="{Binding SystemCollection}"
                                  ItemTemplate="{StaticResource ComponentHDT}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Value.Name}" />
                <TextBlock Text="{Binding Value.AnnotationCount}" Margin="5 0 0 0" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="BuildingHDT"
                                  DataType="{x:Type models:Building}"
                                  ItemsSource="{Binding Buildings}"
                                  ItemTemplate="{StaticResource SystemCollectionHDT}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Value.Name}" />
                <TextBlock Text="{Binding Value.AnnotationCount}" Margin="5 0 0 0" />
            </StackPanel>
        </HierarchicalDataTemplate>

Fredrik
Top achievements
Rank 1
Veteran
Iron
 answered on 14 Sep 2020
2 answers
691 views

When the user drags an item to the top or bottom of the TreeListView, I'd like to scroll automatically, to handle the case where the user wants to drag to an item that isn't currently in view. I have a small sample program I can provide you, and OnDragOver is shown below. Can you tell me how to detect that the drag has reached the top or bottom of the view and then scroll as needed?

Thanks,

Georg Hentsch

        private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) {
            var dropTarget = e.OriginalSource as TreeListViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType<TreeListViewRow>();
            var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails;

            if (dropTarget == null || details == null) {
                return;
            }

            details.CurrentDraggedOverItem = dropTarget.DataContext;

            if (details.CurrentDraggedItem == details.CurrentDraggedOverItem) {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }

            details.CurrentDropPosition = GetDropPositionFromPoint(e.GetPosition(dropTarget), dropTarget);

            if (IsChildOf(dropTarget, sourceItem)) {
                e.Effects = DragDropEffects.None; // don't allow item to be dropped to one of its own children
            }

            e.Handled = true;
        }

 

Georg
Top achievements
Rank 1
Veteran
 answered on 12 Sep 2020
3 answers
588 views

Dear Telerik Team,

I am using telerik Rad Grid View control and having issue with below code.

I am trying to set the background color of a row on mouse over.

Issue is On mouse over below Setter property 'Background' does not set the background color of the row instead it sets the border color. Pl advise on the correct Implementation.

<telerik:RadGridView x:Name="radGridView" Margin="8,100,0,0"
                            ItemsSource="{Binding Source={StaticResource AuthorsData}}"
                           IsFilteringAllowed="True"
                           AutoGenerateColumns="True" Grid.Column="1" >
            <telerik:RadGridView.RowStyle>
                <Style TargetType="telerik:GridViewRow">
                    <Setter Property="MinHeight" Value="20"/>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="Green"/>
                            <Setter Property="Foreground" Value="Black"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </telerik:RadGridView.RowStyle>
        </telerik:RadGridView>

Thanks,
Vaibhav.

Dilyan Traykov
Telerik team
 answered on 11 Sep 2020
1 answer
145 views

Hi 

We have a radoutlookbar with some items in it When te user click on the minimize/restore-button ((1) in attached image)  it works perfect, the bar and all it content moves out and in. (see attached image). 

When user clicks on the "header" of the outlookbar ((2) in attached image) strange things happen. First click is most often than only the first  user control in the first item slides out, after that, sometimes the entire outlookbar is stuck half minimized and we have to restart the application. 

 

First of all, Im I doing something wrong in my xaml (below)? 

If not, is there any setting where I can make the rest of the outlookbar to minimiza/restore or could I catch the event and programmatically restore it? (We are using te MVVM approach) 

--xaml---------------------------------------

<telerik:RadOutlookBar DockPanel.Dock="Right" Width="600" IsVerticalResizerVisible="True" MinimizedButtonContent="Details" IsMinimized="True"  >
     <telerik:EventToCommandBehavior.EventBindings>
           <telerik:EventBinding EventName="SelectionChanged" Command="{Binding DrawerItemChangedCommand}" PassEventArgsToCommand="True"/>
           <telerik:EventBinding EventName="Restored" Command="{Binding ExpandCollapseDrawerCommand}" PassEventArgsToCommand="True"/>
           <telerik:EventBinding EventName="Minimized" Command="{Binding ExpandCollapseDrawerCommand}" PassEventArgsToCommand="True"/>
      </telerik:EventToCommandBehavior.EventBindings>
      <modelview:OneView DataContext="{Binding OneViewModel}"/>
      <telerik:RadOutlookBarItem Header="Another">
             <modelview:AnotherView DataContext="{Binding AnotherViewModel}" />
       </telerik:RadOutlookBarItem>
       <telerik:RadOutlookBarItem Header="LastViewIPromise">
                <moCompliance:LastView DataContext="{Binding LastViewModel}" />
        </telerik:RadOutlookBarItem>
</telerik:RadOutlookBar>

-------------------------------------------------

 

Thanks in advance, Robert

Dilyan Traykov
Telerik team
 answered on 10 Sep 2020
7 answers
256 views
Is there any way to have RadTileViewItems span more than one column or more than one row when in the restored state? If not would you consider this a feature request?

regards

// charlie
Martin Ivanov
Telerik team
 answered on 10 Sep 2020
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
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
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
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?