Telerik Forums
UI for WPF Forum
1 answer
21 views

I have a quite strange behavior for ComboBox

When I set IsReadOnly to true the ReadOnlyBorderBrush of the theme is apllied but ReadOnlyBackBrush is not, also it is not really read only value can still be changed by the user. To avoid this I have set IsReadOnly to true and IsEnabled to false in that case neither Border nor BackBrush is applied.

What am I missing here?

Here is a example 1st Combox has IsReadOnly="True" IsEnabled="False", 2nd Combox only IsReadOnly="True" and at the bottom a TextBox with only IsReadOnly="True" as reference.

Stenly
Telerik team
 answered on 24 Feb 2025
1 answer
70 views

I've been working with the Telerik WPF controls for the last couple of months and appreciating them.

<rant>

However, I have a major gripe as well:  most of the examples are FAR too complex.  Here's a perfect example.  I'm trying to get a ComboBox to work with a GridView.  There is an example that does pretty much exactly what I want at https://github.com/telerik/xaml-sdk/tree/master/ComboBox/DropDownWithHeaders.  However,

  1. A simple clone from the repository won't run.  That seems fundamental to me.  When I look into it, the problem is themes.  A simple example should not even include themes!  I would suggest a proper example would allow me to clone and run, with nothing else on my machine but Visual Studio.
  2. When I look into the actual example, it is anything but simple!  The control template is 155 lines of code!?!?!  How do I sort through that quickly and figure out what I need and don't need?  I don't need all kinds of animation or fancy styles.  For the purposes of learning the controls, I need the absolute minimum to make it work!

There is also an example of this at https://www.telerik.com/forums/radcombobox-with-radgridview, but it suffers from the same problems.

This kind of thing seriously makes me ponder going back to our old controls provider.

</rant>

Now, can someone please provide me with a simple example of a ComboBox that uses a GridView for the drop-down?

Of course perhaps I'm using the wrong control.  Maybe I should be using the MultiColumnComboBox, but the end results shown in the examples make it look nothing like a traditional ComboBox.  (Again, that may be owing to a lack of a good, simple example.)

Help?

Stenly
Telerik team
 answered on 26 Nov 2024
1 answer
58 views

We were using a standard Window object as the parent for our MainWindow. All was good. Then we wanted to do theming...couldn't do it easily, we found we needed to change to telerik:RadWindow. That's when everything went.....bad. No more window icons, no more task bar icon, no more showing up in taskbar. We've been able to figure out msot things and add more code to "fix" what we thought should be part of the default behaviour.

Then this morning my boss uses the mouse to try to change a value in a RadComboBox.....nope. Huh? I must have done something wrong? I don't think so. The change is in git and linked to the exact date we changed from Window to RadWindow..

How are you supposed to get mouse selections to work with a RadComboBox contained in a RadWindow?

Peter
Top achievements
Rank 1
Iron
 answered on 28 Aug 2024
0 answers
78 views

Hi,

 

I would like to have the DataFormComboBoxField  behave the same way as the Edit mode: Editable, Read-Only and Auto Complete ad in your demo application. But when I set it to readonly it is disabled.

My code:

e.DataField = new DataFormComboBoxField()
{
    ItemsSource = _componentsDS.ComponentKeyWords,
    SelectedValuePath = "KeyWordId",
    DisplayMemberPath = "Abbreviation",
    DataMemberBinding = new Binding("KeywordId") { Mode = BindingMode.TwoWay },
    IsComboboxEditable = true,
    IsReadOnly = true,
    Label = "Keyword"
};

 

The example in your application:

 

Kind regards,

 

Johan

Johan Kramer
Top achievements
Rank 1
 asked on 21 Aug 2024
0 answers
49 views

i have a combo box that i need when i select one of it's items, it will open a new sub combo box to choose a sub item

 

is it feasible?

Wael
Top achievements
Rank 1
Iron
 asked on 07 May 2024
0 answers
82 views
I have a controls on a <UserControl> the first of which is a <telerik:RadComboBox>
I have another control that is a <telerik:RadWatermarkTextBox>
I want the second control to have the focus after the screen loads because the combobox has the OpenDropDownOnFocus property set to true.

I use txtPolicyNumber.Focus(); in the after load event but the Combobox grabs the focus.

I even have this code and it still goes to the combobox:

Any suggestions as to what I can do to make Focus() focus?
FrameworkElement focusedElement = Keyboard.FocusedElement as FrameworkElement;
if (focusedElement != null) 
{
    string focusedControlName = focusedElement.Name;
    if (focusedControlName == "txtPolicyNumber")
    {
        iefInsuranceThirdPartyVM.CanAutoDrop = true;
        txtPolicyNumber.Focus();    // WTF is making it focus on the combobox
    }
}


Paul
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 27 Feb 2024
0 answers
84 views

We have a issue with WPF RadComboBox to disable the auto selection of first item while databinding.

I have large set of data (say 10000 items) in the application cache.

<telerik:RadComboBox
                                        x:Name="itemBox"
                                        HorizontalAlignment="Stretch"
                                        telerik:TextSearch.TextPath="Name"
                                        CanAutocompleteSelectItems="False"
                                        DisplayMemberPath="Name"
                                        EmptyText="Select item"
                                        IsEditable="True"
                                        IsFilteringEnabled="True"
                                        IsReadOnly="False"
                                        IsTextSearchEnabled="True"
                                        ItemsSource="{Binding ItemCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                        OpenDropDownOnFocus="True"
                                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                                        SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                        TextSearchMode="Contains">

                                                <telerik:EventBinding
                                                Command="{Binding BeginSearchCommand}"
                                                EventName="KeyUp"
                                                PassEventArgsToCommand="True" />
</telerik:RadComboBox>

We have the RadCombobox with Filter enabled.

BeginSearchCommand relay command method has implementation of filtering the cached ItemCollection and setting the value.


this.ItemCollection = new QueryableCollectionView(new ObservableCollection<ItemModel>(filtereditems));

I first load 50 items in RadCombobox and the user will try to search the items from SearchText . Then the items in the cache is filtered with searchtext and the result is assigned with the datasource property.

  1. User start searching
  2. The first item from the filtered result occupies the search text.

The couple of action above continues. Please help us disable autoselect  while databinding.

Praveenraj
Top achievements
Rank 1
 updated question on 24 Feb 2024
1 answer
84 views

Hi,

I have a problem, that I cannot solve. I have a Grid View (see attachment) based on a SQL Table. Now have replaced some colums with a comboBox.

The comboBoxes receive the data from the following table.

| ID  |  Country |  Plant  |  Area  |  Machine |
------------------------------------------------
|  1  |   DE     |   MUC   |  BA    |   A      |
|  2  |   DE     |   MUC   |  BA    |   A      |
|  3  |   AT     |   VIE     |  BE    |    1      |
|  4  |   AT     |   VIE     |  BE    |    2      |

F.e. The column "Country" in my GridView has as ItemSource a grouping of the column Country. Now I want to update the comboBox "Plant" depending on the value of the ComboBox "Country" meaning that when "DE" is chosen, it should only show "MUC" as a possible entry. How can I do that? Here is my code.

Thanks.


 public partial class MainWindow : Window
 {
     private SqlConnection connection;
     private string dbName = string.Empty;
     
     public MainWindow()
     {
         InitializeComponent();
         LoadData();
     }

     private void LoadData()
     {

         try
         {
             string connectionString = "Data Source=localhost;Initial Catalog=Test_DB;Integrated Security=True";
             using (SqlConnection connection = new SqlConnection(connectionString))
             {
                 connection.Open();
                 string query = "SELECT * FROM dbo.MachineAreas";
                 SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
                 DataTable dataTable = new DataTable();
                 adapter.Fill(dataTable);

                 gridMachineAreas.ItemsSource = dataTable.DefaultView;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message);
         }
     }

     private void GridMachineAreas_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
     {            

         switch ((e.Column as GridViewDataColumn).DataMemberBinding.Path.Path)
         {
             case "ID":
                 var newColumn1 = new GridViewDataColumn();
                 newColumn1.CopyPropertiesFrom(e.Column);
                 newColumn1.Header = "ID";
                 newColumn1.Width = 60;
                 e.Column = newColumn1;
                 break;

             case "Country":
                 var newColumn2 = new GridViewComboBoxColumn();
                 newColumn2.CopyPropertiesFrom(e.Column);
                 newColumn2.Header = "Country";
                 newColumn2.Width = 60;
                 newColumn2.UniqueName = "Country";
                 newColumn2.IsComboBoxEditable = false;
                 newColumn2.ItemsSource = MakeCountryCollection();                    
                 
                 e.Column = newColumn2;
                 break;
             case "Plant":
                 var newColumn3 = new GridViewComboBoxColumn();
                 newColumn3.CopyPropertiesFrom(e.Column);
                 newColumn3.Header = "Plant";
                 newColumn3.Width = 60;                    
                 e.Column = newColumn3;
                 break;
             case "Area":
                 var newColumn4 = new GridViewComboBoxColumn();
                 newColumn4.CopyPropertiesFrom(e.Column);
                 newColumn4.Header = "Area";
                 newColumn4.Width = 60;
                 e.Column = newColumn4;
                 break;
             case "Machine":
                 var newColumn5 = new GridViewComboBoxColumn();
                 newColumn5.CopyPropertiesFrom(e.Column);
                 newColumn5.Header = "Machine";
                 newColumn5.Width = 60;
                 e.Column = newColumn5;
                 break;
         }

     }

     private List<string> MakeCountryCollection()
     {
         List<string> countryCollection = new List<string>();
         string query = "SELECT Country FROM dbo.MachineAreas Group By Country";
         
         try
         {
             string connectionString = "Data Source=localhost;Initial Catalog=Test_DB;Integrated Security=True";
             using (SqlConnection connection = new SqlConnection(connectionString))
             {
                 connection.Open();


                 using (SqlCommand command = new SqlCommand(query, connection))
                 {
                     using (SqlDataReader reader = command.ExecuteReader())
                     {


                         while (reader.Read())
                         {
                             string value = reader.GetString(0);
                             countryCollection.Add(value);
                         }
                         
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message);
         }
         return countryCollection;
     }
 }


Dimitar
Telerik team
 answered on 12 Dec 2023
0 answers
121 views

Hello, Telerik

I want to create a feature with the following characteristics:

1. Use of the MVVM pattern.
2. The number of columns in the DataGridView is not fixed but dynamic. (Users can specify the number of columns as an option, allowing for dynamic changes.)
3. Only the first column's text is fixed, while the 2nd to nth columns are ComboBoxes, allowing users to select which columns they want to view.

For example, if a class has (name, age, gender, department, major, student number, average grade, highest grade, lowest grade) as fields,
'Name' is always shown in the first column as fixed data.
'Age' to 'Lowest Grade' are available as ComboBox options for users to select and view as they wish.

If n = 5, it could be displayed as follows:

      1st               | 2nd |    3rd    |     4th |    5th
Name (Fixed) | Age | Gender | Major | Avg Score

or
       1st             | 2nd    |      3rd         | 4th         | 5th
Name (Fixed) | Major | Avg Score | Max Score | Min Score

In this way, users can view data in the columns of their choice.

As mentioned, since the number of columns is dynamic, I don't want to write the column code as below.

<telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="column 1" DataMemberBinding="{Binding data_1}"/>
                <telerik:GridViewDataColumn Header="column 2" DataMemberBinding="{Binding data_2}"/>
                <telerik:GridViewDataColumn Header="column .." DataMemberBinding="{Binding data_1}"/>
                <telerik:GridViewDataColumn Header="column n" DataMemberBinding="{Binding data_n}"/>

</telerik:RadGridView.Columns>

 

I searched all the SDK examples and forums, but I don't know how to write it.

Thank you in advance.

Kim
Top achievements
Rank 1
 asked on 04 Dec 2023
0 answers
85 views

Hi,

We have an old application (VB6) that we are migrating to WPF and .NET 8. I use your WPF controls in this application. We use this application to creat test templates for different instruments.
Each test template consists of one or more subtest templates. Each subtest template consists of a test grid with different number of rows and columns, depending of instrument and type of test.
The subtest template grids data is stored in a database. Each subtest are stored in one table, each column number is stored in one table with foreign key to the subtest table, each cells value and row number is stored in one table with foreign key to the column table.  

So far I have managed read data to my gridview with the help of your article https://docs.telerik.com/devtools/wpf/controls/radgridview/how-to/use-mixed-clr-dlr-properties.

First question,
I want the 4 first rows to be comboboxes, different combobox data for each row. I have been able to get comboboxes with DataTempletSelector, DataTemplate and RadGridView_AutoGeneratingColumn,
with help from this forum post from Petar Mladenov https://www.telerik.com/forums/unable-to-use-datatemplates-with-gridview-dynamic-data-not-even-with-icustomtypeprovider.
But my problem is that I don't get any data in the comboboxes. So how should I define my combobox so it databinds to my collection of comboboxdata? 

Second question,
If I manage to fill the comboxes with data I don't know how to databind selectedvalue to my ObservableCollection<MyDataRow>, so how can I do that?
The rest of the gridcells are textboxes and they databinds automatically and updates my ObservableCollection<MyDataRow> when I change a value in a cell.

This is my gridview,

                    <telerik:RadGridView  x:Name="TestCasesGridView"
                                          ItemsSource="{Binding SubtestTestCases, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, BindsDirectlyToSource=True}"
                                          IsFilteringAllowed="False"
                                          CanUserSortColumns="False"
                                          ShowColumnHeaders="True"
                                          ShowSearchPanel="True"
                                          SearchMode="MatchAllTerms"
                                          SearchPanelCloseButtonVisibility="Collapsed"
                                          IsSynchronizedWithCurrentItem="False"
                                          AutoGenerateColumns="True"
                                          AutoGeneratingColumn="RadGridView_AutoGeneratingColumn"
                                          Margin="10"
                                          IsReadOnly="False"
                                          ShowGroupPanel="False"
                                          RowIndicatorVisibility="Collapsed"
                                          Height="Auto"
                                          Width="Auto"
                                          ScrollMode="Deferred"
                                          ClipboardCopyMode="Default"
                                          ClipboardPasteMode="AllSelectedRows"
                                          SelectionMode="Single"
                                          SelectionUnit="FullRow"
                                          ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                          ScrollViewer.VerticalScrollBarVisibility="Auto"
                                          CanUserSelectColumns ="False"
                                          GroupRenderMode="Flat">
                    <telerik:RadGridView.Columns>
                        <helper:MyColumn Header="#"
Width="30" TextAlignment="Center"/>
                    </telerik:RadGridView.Columns>
                    <telerik:RadGridView.Resources>
                        <helper:MyCellTemplateSelector x:Key="myCellTemplateSelector">
                            <helper:MyCellTemplateSelector.ColumnNames>
                                <DataTemplate>
                                    <telerik:RadComboBox ItemsSource="{Binding ColumnNames}" DisplayMemberPath="KBE_Ben" OpenDropDownOnFocus="True"/>
                                </DataTemplate>
                            </helper:MyCellTemplateSelector.ColumnNames>
                            <helper:MyCellTemplateSelector.ColumnUnit>
                                <DataTemplate>
                                    <telerik:RadComboBox ItemsSource="{Binding ColumnUnits}" DisplayMemberPath="KEN_Kod" OpenDropDownOnFocus="True"/>
                                </DataTemplate>
                            </helper:MyCellTemplateSelector.ColumnUnit>
                            <helper:MyCellTemplateSelector.ColumnInfo>
                                <DataTemplate>
                                    <telerik:RadComboBox ItemsSource="{Binding ColumnInfos}" DisplayMemberPath="INF_InfoRad" OpenDropDownOnFocus="True"/>
                                </DataTemplate>
                            </helper:MyCellTemplateSelector.ColumnInfo>
                            <helper:MyCellTemplateSelector.ColumnProperty>
                                <DataTemplate>
                                    <telerik:RadComboBox ItemsSource="{Binding ColumnProperties}" DisplayMemberPath="KEG_Namn" OpenDropDownOnFocus="True"/>
                                </DataTemplate>
                            </helper:MyCellTemplateSelector.ColumnProperty>
                        </helper:MyCellTemplateSelector>
                    </telerik:RadGridView.Resources>
                </telerik:RadGridView>

 

Stefan
Top achievements
Rank 1
 asked on 23 Nov 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?