Telerik Forums
UI for WPF Forum
0 answers
61 views

I want to save the expansion state of my TreeListView before I reload the data and I use the following code:


foreach (var item in _currentTreeListView.Items)
{
    if (_currentTreeListView.IsExpanded(item))
    {
        expandedItems.Add(item);
    }
}

// Data update and TreeListView reload

foreach (var item in expandedItems)
{
    _currentTreeListView.ExpandHierarchyItem(item);
}

But _currentTreeListView.IsExpanded(item) returns false no matter if the corresponding item is expanded in the TreeListView. What's the problem?

D
Top achievements
Rank 1
 asked on 02 Aug 2024
0 answers
43 views

DELETE THIS QUESTION

Juan
Top achievements
Rank 1
 updated question on 01 Aug 2024
0 answers
99 views

        <Style TargetType="telerik:TreeListViewRow">
            <Setter Property="SelectedBackground" Value="Red"/>
        </Style>

I set the SelectedBackground property, but it didn't work. I hope you can tell me what to do?

YunFan
Top achievements
Rank 1
 asked on 01 Aug 2024
1 answer
73 views

Hello,

 

I need some advice about RadAutoCompleteBox.

When I click on RadAutoCompleteBox I want to see all possible results and then I will have a option to choose whether I want to select from them or start searching by typing.  Searching for text and then selecting works fine, but unfortunately searching with nothing in it doesn't work. When I click on RadAutoCompleteBox all the results are displayed, but I can't select anything from them until I type something. The hover selection works fine, I just can't select anything if RadAutoCompleteBox.SearchText is empty. Could you help me how to solve this? Thank you very much.

I am sending part of my the source code and example (WpfApp1.zip) where it also not working.


... 
 <controls:RadAutoCompleteBoxFilter x:Key="RadAutoCompleteBoxFilter" />
...
     <telerik:RadAutoCompleteBox Grid.Row="0"
                      x:Name="CaseAutoCompleteBox"
                      WatermarkContent="{x:Static rs:ResourceText.Start_Typing}"
                      ItemsSource="{Binding Suggestions}"
                      SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                      TextSearchMode="Contains"
                      TextSearchPath="Name"
                      DisplayMemberPath="Name"
                      AutoCompleteMode="SuggestAppend"
                      DropDownItemTemplate="{StaticResource CasesSearchAutoComplete}"
                      SelectionMode="Single"
                      SelectionChanged="CaseAutoCompleteBoxSelectionChanged"
                      PreviewMouseLeftButtonDown="OnPreviewMouseLeftButtonDown"
                      GotFocus="CaseAutoCompleteBox_OnGotFocus"
                      FilteringBehavior="{StaticResource RadAutoCompleteBoxFilter}"
                    
                      />



 public partial class AddMediaToCase 
 {
     public AddMediaToCase()
     {
         InitializeComponent();
         RadWindowInteropHelper.SetShowInTaskbar(this, true);
     }

     private void CaseAutoCompleteBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
     {
         var autoCompleteBox = sender as RadAutoCompleteBox;
         CaseInformationStackPanel.Visibility = autoCompleteBox.SelectedItem != null ? Visibility.Visible : Visibility.Collapsed;
     }

     private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
     {

         if (string.IsNullOrWhiteSpace(CaseAutoCompleteBox.SearchText))
         {
             CaseAutoCompleteBox.Populate(" ");
             
         }


     }

     private void CaseAutoCompleteBox_OnGotFocus(object sender, RoutedEventArgs e)
     {
         if (string.IsNullOrWhiteSpace(CaseAutoCompleteBox.SearchText))
         {
             
             CaseAutoCompleteBox.Populate(" ");
         }

     }
 }


  public class RadAutoCompleteBoxFilter : FilteringBehavior
  {
      public override IEnumerable<object> FindMatchingItems(string searchText, IList items,
          IEnumerable<object> escapedItems, string textSearchPath,
          TextSearchMode textSearchMode)
      {
          var result =
              base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode) as
                  IEnumerable<object>;

          if (string.IsNullOrEmpty(searchText) || !result.Any())
          {
              return ((IEnumerable<object>)items).Where(x => !escapedItems.Contains(x));
          }

          return result;
      }
  }


 

Martin Ivanov
Telerik team
 answered on 30 Jul 2024
1 answer
109 views

Package: Telerik.UI.for.Wpf.70, Version=2024.2.514

I include all necessary theme files for Windows 11 theme in App.xaml:

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Windows11;component/Themes/System.Windows.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Windows11;component/Themes/Telerik.Windows.Controls.xaml"/>
                ...
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

I place a simple Button and RadButton inside MainWindow.xaml. When running in this configuration the buttons are visible, the correct theme is assigned. (see screenshot 1)

When placing Windows11Palette.LoadPreset(Windows11Palette.ColorVariation.Dark); inside OnStartup of Application the buttons disappear during runtime. (see screenshot 2)

What am I missing here? The same is with Fluent theme. Other themes like Office2019 work perfectly.

TIA
Heiko

Martin Ivanov
Telerik team
 answered on 30 Jul 2024
1 answer
67 views

Hi,

We are creating a table which then gets inserted into a RichTextBox. We need to add a DocumentVariableField to one of the cells, can anyone please advise.


// The field which needs to be added o the table
            
doc_text.Document.DocumentVariables.Add("1001", addrName);
DocumentVariableField docVariable = new DocumentVariableField() { VariableName = "1001"  };
           
doc_text.InsertField(docVariable, FieldDisplayMode.Result);
            

RadDocument document = new RadDocument();
Section section = new Section();

TableWidthUnit w1 = new TableWidthUnit(100);
TableWidthUnit w2 = new TableWidthUnit(520);

Table table = new Table();
table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

TableRow row1 = new TableRow();
TableCell cell1 = new TableCell();
cell1.Background = Color.FromRgb(174, 255, 190);
cell1.PreferredWidth = w1;
cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
Paragraph p1 = new Paragraph();
Span s1 = new Span();
s1.FontWeight = FontWeights.Bold;
s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
s1.Text = "Name";
p1.Inlines.Add(s1);
cell1.Blocks.Add(p1);
row1.Cells.Add(cell1);

TableCell cell2 = new TableCell();
cell2.Background = Color.FromRgb(174, 255, 190);
cell2.PreferredWidth = w2;
cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
Paragraph p2 = new Paragraph();
Span s2 = new Span();
s2.FontWeight = FontWeights.Bold;
s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            
s2.Text = addrName;  // We need to change this to the DocumentVariableField
p2.Inlines.Add(s2);
cell2.Blocks.Add(p2);
row1.Cells.Add(cell2);
table.Rows.Add(row1);

section.Blocks.Add(new Paragraph());
section.Blocks.Add(table);
section.Blocks.Add(new Paragraph());
document.Sections.Add(section);

doc_text.Document = document;

 

Many thanks

Dimitar
Telerik team
 answered on 26 Jul 2024
1 answer
92 views

Hi,

We are creating a table and adding it to a RichTextBox:


        public void AddAddress()
        {
            string addrName = string.Empty;
            string[] rowName = new string[] { "Job Title", "Employer", "Address", "Tel.", "Tel. Dir.", "Mobile", "Email", "Website", "Fax", "Details", "Address", "Tel.", "Mobile", "Email", "Details" };
            if(_selelement != null)
            {
                addrName = _selelement.GetAttribute("title");
            }
            SdtProperties sdtProperties = new SdtProperties(SdtType.RichText)
            {
                Alias = "AddressName",
                Lock = Lock.SdtContentLocked,
                ID = 1001,
            };
            RadDocument document = new RadDocument();
            Section section = new Section();

            TableWidthUnit w1 = new TableWidthUnit(100);
            TableWidthUnit w2 = new TableWidthUnit(520);

            Table table = new Table();
            table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

            TableRow row1 = new TableRow();
            TableCell cell1 = new TableCell();
            cell1.Background = Color.FromRgb(174, 255, 190);
            cell1.PreferredWidth = w1;
            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
            Paragraph p1 = new Paragraph();
            p1.Background = Color.FromRgb(174, 255, 190);
            Span s1 = new Span();
            s1.FontWeight = FontWeights.Bold;
            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            s1.Text = "Name";
            p1.Inlines.Add(s1);
            cell1.Blocks.Add(p1);
            row1.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            cell2.Background = Color.FromRgb(174, 255, 190);
            cell2.PreferredWidth = w2;
            cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
            Paragraph p2 = new Paragraph();
            p2.Background = Color.FromRgb(174, 255, 190);
            Span s2 = new Span();
            s2.FontWeight = FontWeights.Bold;
            s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
            s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            s2.Text = addrName;
            p2.Inlines.Add(s2);
            cell2.Blocks.Add(p2);
            row1.Cells.Add(cell2);
            table.Rows.Add(row1);

            int rowCount = 0;
            foreach(string rname in rowName)
            {
                rowCount++;
                row1 = new TableRow();
                cell1 = new TableCell();
                p1 = new Paragraph();
                if (rowCount < 11)
                {
                    cell1.Background = Color.FromRgb(255, 229, 153);
                    p1.Background = Color.FromRgb(255, 229, 153);
                }
                else
                {
                    cell1.Background = Color.FromRgb(196, 255, 255);
                    p1.Background = Color.FromRgb(196, 255, 255);
                }
                cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                s1 = new Span();
                s1.FontWeight = FontWeights.Bold;
                s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s1.Text = rname;
                p1.Inlines.Add(s1);
                cell1.Blocks.Add(p1);
                row1.Cells.Add(cell1);

                cell2 = new TableCell();
                cell2.Background = Color.FromRgb(255, 255, 255);
                cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                p2 = new Paragraph();
                s2 = new Span();
                s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s2.Text = " ";
                p2.Inlines.Add(s2);
                cell2.Blocks.Add(p2);
                row1.Cells.Add(cell2);
                table.Rows.Add(row1);
            }

            section.Blocks.Add(new Paragraph());
            section.Blocks.Add(table);
            section.Blocks.Add(new Paragraph());
            document.Sections.Add(section);

            doc_text.Document = document;   
        }

How can we add a Content Control with StdProperties to one of the table cells, similar to:

SdtProperties sdtProperties = new SdtProperties(SdtType.RichText) 
{ 
    Alias = "AliasName", 
    Lock = Lock.SdtContentLocked, 
}; 
doc_text.InsertStructuredDocumentTag(sdtProperties); 

Dimitar
Telerik team
 answered on 26 Jul 2024
1 answer
163 views
how add spinner to WPF Application
Stenly
Telerik team
 answered on 25 Jul 2024
1 answer
68 views

I have the following XAML code:

<telerik:RadLayoutControl >
    <telerik:RadTabControl>
        <telerik:RadTabItem Header="Admin">
            <telerik:RadTabItem.Content>
                <telerik:RadLayoutControl>
				
                    <!-- Left Side -->
                    <telerik:RadTreeListView Name="TreeListView" ItemsSource="{Binding Arguments}">
                        <telerik:RadTreeListView.ChildTableDefinitions>
                            <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
                        </telerik:RadTreeListView.ChildTableDefinitions>
                    </telerik:RadTreeListView>
					
                    <telerik:LayoutControlSplitter />

                    <!-- Right Side -->
                    <telerik:RadTabControl Width="Auto">
                        <telerik:RadTabItem Header="Tab 1">
                            <telerik:RadGridView></telerik:RadGridView>
                        </telerik:RadTabItem>
                        <telerik:RadTabItem Header="Tab 2">
                            <telerik:RadGridView></telerik:RadGridView>
                        </telerik:RadTabItem>
                    </telerik:RadTabControl>

                </telerik:RadLayoutControl>
            </telerik:RadTabItem.Content>
        </telerik:RadTabItem>
    </telerik:RadTabControl>
</telerik:RadLayoutControl>

The problem is that when I populate the TreeListView with big number of items, it stretches the topmost RadLayoutControl parent (look at the scrollbar position on the far right). The behavior I expect is that the TreeListView itself gets a vertical scrollbar like when I set it to a fixed Height. But I want it to be resizable with the window.

How can I achieve such behavior?

Martin Ivanov
Telerik team
 answered on 24 Jul 2024
1 answer
91 views

Hey,

since the last Update, my GridViews with a CellEditTemplate (for example DateTimePickers or MaskedTextInputs) dont show the red Validation Error indicators anymore, if ValidatesOnDataErrors is set to InEditMode.

If you hover over the location where the error should show you can still see it, but no red indicator whatsoever.

If ValidatesOnDataErrors is set to ViewMode it works.
If no CellEditTemplate is set, it works too.

Heres the code of the gridview:

        <telerik:RadGridView
            x:Name="rgv"
            GroupRenderMode="Flat"
            ShowGroupPanel="False"
            FilteringMode="Popup"
            ShowSearchPanel="False"
            CanUserSearch="False"
            ValidatesOnDataErrors="InEditMode"
            AlternationCount="2"
            ActionOnLostFocus="CommitEdit"
            CanUserDeleteRows="True"
            IsSynchronizedWithCurrentItem="True"
            ShowColumnFooters="True"
            SelectionMode="Single"
            IsPropertyChangedAggregationEnabled="False"
            VirtualizingPanel.VirtualizationMode="Recycling"
            NewRowPosition="Top"
            AutoGenerateColumns="False"
            >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding RechnungsNr}"
                    Header="Rechnung Nr."
                    TextWrapping="Wrap"
                    HeaderTextWrapping="Wrap"
                    Width="100"
                    >
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <telerik:RadMaskedTextInput
                                Value="{Binding RechnungsNr, Mode=TwoWay, UpdateSourceTrigger=Explicit}"    
                                maskedInput:MaskedInputExtensions.MaxTextLength="255"
                                Mask=""
                                MinWidth="100"
                                InputBehavior="Insert"
                                IsClearButtonVisible="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="Anzahl:  " ResultFormatString="{}{0:N0}" />
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

 

And also the whole sample project:
https://we.tl/t-11ppqbB7EG

 

Did I miss something I have to change after the update?

Greetings
Benedikt

Stenly
Telerik team
 answered on 23 Jul 2024
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?