Telerik Forums
UI for WPF Forum
1 answer
171 views

Hello!

      I'm using the "RadRichTextBox" in my project. I'm facing a problem when the control is disabled (i.e. IsEnabled = False). In disabled state the controls turns Grey and the text visibility is very low. I cannot use read-only or any other property as they are being used for other purpose. I need to change the template for Disabled control, so as to not make it Grey but make the Disable mask transparent instead. Need help for the same.

Thanks

Tushar

     

Lance | Senior Manager Technical Support
Telerik team
 answered on 05 Dec 2016
3 answers
643 views

I am replacing a TreeView control with a RadTreeView control however I have run in to a issue. I want the user to be able to click on the body of the TreeView (instead of a node) and have it deselect the item in the tree view.

 

With the original TreeView I would do

<TreeView Grid.Row="0" MouseDown="TreeView_OnMouseDown">
    <TreeViewItem Header="Item 1"/>
    <TreeViewItem Header="Item 2"/>
</TreeView>

Then in the code behind I would have

private void TreeView_OnMouseDown(object sender, MouseButtonEventArgs e)
{
    var treeView = (TreeView)sender;
    var items = treeView.Items.Cast<TreeViewItem>();
    foreach (var treeViewItem in items)
    {
        treeViewItem.IsSelected = false;
    }
     
}

 

And this would work correctly. However if I do

<telerik:RadTreeView Grid.Row="1" MouseDown="RadTreeView_OnMouseDown">
    <telerik:RadTreeViewItem Header="Item 3"/>
    <telerik:RadTreeViewItem Header="Item 4"/>
</telerik:RadTreeView>

and

private void RadTreeView_OnMouseDown(object sender, MouseButtonEventArgs e)
{
    var treeView = (RadTreeView)sender;
    treeView.SelectedItem = null;
    MessageBox.Show("RadTreeView_OnMouseDown fired!");
}

the OnMouseDown event never fires.

Looking at the OnMouseDown event with Snoop it appears to be getting marked as handled by the ScrollViewer inside the RadListView.

What is the correct way to deselect the node when clicking on the body of the tree view? Attached is a simple example program that shows the two controls side by side with their different behaviors.

Scott
Top achievements
Rank 1
 answered on 05 Dec 2016
3 answers
251 views

Hi,

At the moment I'm facing an issue, I have a RadGridView which can show different tables with different definitions(not at the same time)
So AutoGenerateColumns is set to True.

now it can happen that some columns have an FK to another table.
Before I replaced those columns in the DataLoaded event but because of performance reasons I would like to do those replaces in the CurrentCellChanged event.

The problem when I do this is that the new GridViewComboBoxColumn misses the link to the actual datasource, and while reading the value for saving in the database, the value is DBNULL.

the gridview in de Xaml looks like this

<DataTemplate x:Key="AdminViewMainSectorTemplate">
        <Grid Margin="10">
            <Grid>
                <telerik:RadBusyIndicator x:Name="BusyIndicator" Grid.Row="2" >
                    <telerik:RadGridView x:Name="gridViewAdminData"
                                                     ItemsSource="{Binding DataRecords, Mode=TwoWay}"
                                         RowEditEnded="EditRecord"
                                         Deleted="deleteRecord"
                                         AddingNewDataItem="AddingNewDataItem"
                                         MinColumnWidth="100"
                                         ColumnWidth="*"
                                         NewRowPosition="Top"                                         
                                         AutoGeneratingColumn="AutoGeneratingColumn"
                                         DataLoading="LoadData"
                                         DataLoaded="DataLoaded"
                                         CurrentCellChanged="CurrentCellChanged"
                                         SelectionUnit="Cell"
                                         >
                        <!--DataLoading="LoadData"
                                         DataLoaded="DataLoaded"-->
                        <telerik:EventToCommandBehavior.EventBindings>
                            <telerik:EventBinding
                            Command="{Binding HandleAddingNewRecordToDevicesGridCommand}"
                            EventName="AddingNewDataItem"
                            PassEventArgsToCommand="True"/>
                        </telerik:EventToCommandBehavior.EventBindings>
                    </telerik:RadGridView>
                </telerik:RadBusyIndicator>
            </Grid>
        </Grid>
    </DataTemplate>

and my code behind looks like this:

private void CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e)
       {
           RadGridView rgv = (RadGridView)sender;
           GridViewCell cell = rgv.CurrentCell;
           if (cell != null && typeof(GridViewDataColumn) == cell.Column.GetType())
           {
               Models.MyEntities db = new Models.MyEntities();
               string tableName = Helpers.GlobalParameters.currenTableName;
               if (tableName =="batches")
               {
                   string fieldname = cell.Column.UniqueName;
                   if (fieldname == "ProductieOrderId")
                   {
                       int index = cell.Column.DisplayIndex;
                       GridViewComboBoxColumn cbb = new GridViewComboBoxColumn();
                       cbb.DataMemberBinding = new System.Windows.Data.Binding(fieldname);
                       //cbb.DataMemberBinding = cell.DataColumn.DataMemberBinding;
                       cbb.ItemsSource = db.productieorder.ToList();
                       cbb.SelectedValueMemberPath = fieldname;
                       cbb.DisplayMemberPath = "Id";
                       //cbb.Name = fieldname;
                       cbb.UniqueName = fieldname;
                       cbb.DisplayIndex = index;
                       rgv.Columns.Remove(cell.Column);
                       //rgv.Columns.Remove(cell.DataColumn);
                       rgv.Columns.Add(cbb);
 
                   }
               } else if (tableName =="artikel")

where the Field "Id" is the related field on the related table
If I do this
cbb.SelectedValueMemberPath = "Id";

what I would say is logical, the shown value in the combobox stays empty.

does anyone know where to look to fix this issue?

Martin
Telerik team
 answered on 05 Dec 2016
1 answer
208 views

Hi,

I am using a DataTemplateSelector and DataTemplates to show and interact with Custom Appointments in the schedule.

The Custom Appointment has a field called BindingItem added which holds a reference to my data.I then have checkboxes and drop down boxes that bind to fields within the BindingItem.

Everything works great until I refresh the entire appointments collection.

It seems like DataTemplates are being reused (by the container?) and any interaction seems to be with the old BindingItem not the new one, even though the appointment collection is brand new and each appointment has a new BindingItem set.

I can get this resolved in 2 ways, the first is to scroll the offending appointments off the screen and back again which must be forcing some kind of container refresh. Not very useful for end users.

The second is to use the following code to force a container refresh, note that AddIdleAction adds the code onto the dispatcher at application idle priority:

        private void RefreshAppointmentBindingItem(CustomAppointment appt)
        {
            if (appt != null)
            {
                object item = appt.BindingItem;

                AddIdleAction(() =>
                {
                    appt.BindingItem = null;
                });

                AddIdleAction(() =>
                {
                    appt.BindingItem = item;
                });
            }
        }

Both ways are messy, do you have any better suggestions?

Thanks

Anthony

Stefan
Telerik team
 answered on 05 Dec 2016
6 answers
164 views
I have an RTF document that is made up of many smaller RTF documents merged together.  The document that I am using for testing contains over 1100 pages. Printing this document setting the Document property of a RadRichTextBox and calling the print method is very slow.  I can open the same document in Word and it prints about 10 times faster.  Are there any recommendations for improving printing performance?  Thanks.
tushar
Top achievements
Rank 1
 answered on 05 Dec 2016
1 answer
95 views

Basically, when the use hits the OK button in the raddataform for a particular row I want to collapse the details.

An Mvvm friendly solution would be great!

Thanks ... Ed

 

Dilyan Traykov
Telerik team
 answered on 05 Dec 2016
1 answer
272 views

Also with RadListBox, of course. This is using the VisualStudio 2013 theme.

Simple repro:

Create a ListBox with IsEnabled=false.

Add a CheckBox item, with a Content="Testing" or whatever.

Notice that it is very dark, nearly unreadable. It's because in your theme XAML, you have set the RadListBoxItem disabled state contentPresenter to an Opacity of 0.2. Now, inside of a CheckBox, you also have similar code for the disabled state where the content's Opacity is set to 0.2.

Guess what? The 2 values multiply, which means now the CheckBox has an effective Opacity value of 0.2*0.2 = 0.04. :( That's dark.

I can see why this was done, because if your ListBox has strings only, then it works, because a TextBlock doesn't have a disabled state. Yeah, but what if your ItemTemplate has controls that they themselves have a darkened disabled state??? That doubles up the disabled-ness.

I like how Microsoft handles it by changing the Foreground to grey in their themes instead of screwing with Opacity (since Foreground is inherited), and that would work perfectly in both my cases, string-only lists and checkbox lists.

 

Martin
Telerik team
 answered on 05 Dec 2016
3 answers
252 views
I am using the trial for WPF and i have a datagrid set up with a 10 visible columns and 20+ that are hidden.

I have the search panel show above the datagrid. i would like to search for values in the hidden columns.

 

For example, the datagrid shows locations and address of buildings. lets say i want to find a record where 'Comments' column contains "secret message"

 

Visual aid: https://www.dropbox.com/s/6mfcxlvz2qhzqjd/Untitled.png?dl=0

Martin
Telerik team
 answered on 05 Dec 2016
6 answers
690 views

I am using the checkboxes in a RadTreeView. The treeview items are bound to my own heirarchical type called TreeNode. When an item is checked how do I determine which TreeNode object was checked?

Currently I am using a command to handle the IsChecked event of the control. I am passing the event arguments to the command. I can get access to all the checked items in the tree as TreeNodes, but am at a loss as to which one was actually last checked.

 <telerik:RadTreeView x:Name="TreePermissions"
                                                 DockPanel.Dock="Top"
                                                 MinHeight="50"
                                                 BorderBrush="Black"
                                                 BorderThickness="1"
                                                 Margin="5,0,5,0"
                                                 IsOptionElementsEnabled="True"
                                                 ItemsSource="{Binding UserPermissions}"
                                                 ItemPrepared="TreePermissions_ItemPrepared">
                                
                                <telerik:EventToCommandBehavior.EventBindings>
                                    <telerik:EventBinding Command="{Binding PermissionCheckedCommand}" EventName="Checked"
                                                          PassEventArgsToCommand="True" />
                                </telerik:EventToCommandBehavior.EventBindings>
                                
                                <telerik:RadTreeView.ItemContainerStyle>
                                    <Style TargetType="{x:Type telerik:RadTreeViewItem}">
                                        <Setter Property="IsExpanded" Value="True"/>
                                        <Setter Property="IsChecked" Value="{Binding IsChecked, UpdateSourceTrigger=PropertyChanged}"/>
                                        <Setter Property="IsEnabled" Value="{Binding IsEnabled, UpdateSourceTrigger=PropertyChanged}"/>
                                    </Style>
                                </telerik:RadTreeView.ItemContainerStyle>
                            </telerik:RadTreeView>

 

private void OnPermissionChecked(object obj)
        {
            var args = obj as Telerik.Windows.Controls.RadTreeViewCheckEventArgs;
            Telerik.Windows.Controls.RadTreeViewItem item = args.OriginalSource as Telerik.Windows.Controls.RadTreeViewItem;
            // TreeNode node = item as TreeNode; // This does not work, cannot cast/convert for some reason
            Telerik.Windows.Controls.RadTreeView source = args.Source as Telerik.Windows.Controls.RadTreeView;
            if (source != null)
            {
                List<TreeNode> temp = source.CheckedItems.Cast<TreeNode>().ToList();
            }
        }

Heiko
Top achievements
Rank 1
 answered on 05 Dec 2016
1 answer
94 views
I am using a RadDateTimePicker to allow a user to select, strangely enough, a date and time.  I set the date for the control to some value (e.g. 8/16/2016 4:03 AM) which it happily displays (see attached DatePickerOK.jpg).  However, when the user clicks the button to pop up the picker, the calendar header says "January - 1000" (see attached DatePickerError.jpg) instead of the expected "August - 2016".  If the user selects a different time and closes the picker window, the text box displays the newly selected time along with the CORRECT month/day.  What am I missing?
Nasko
Telerik team
 answered on 05 Dec 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?