Telerik Forums
UI for WPF Forum
3 answers
183 views
Hello

Please refer to the telerik "Save/Load the Content of the Panes" docking topic. I'm trying to load the layout of my docking control in this way when navigating away and then returning to this screen to maintain view state. This page refers to the following piece of code:
private void radDocking_ElementLoading( object sender, Telerik.Windows.Controls.LayoutSerializationLoadingEventArgs e )
{
    var pane = e.AffectedElement as RadPane;
    if ( pane != null )
    {
        pane.Content = this.GetPaneContent( e.AffectedElementSerializationTag );
    }
}

I assume that "GetPaneContent" refers to some internal method in the code-behind which returns the content, whatever that control may have been before the content was saved. Since I am using MVVM and adding RadPanes and RadPaneGroups dynamically in my view model, I maintain a dictionary of the pane contents by the serialization tag that I assign to each one. This view model code is as follows:

RadPaneGroup radPaneGroup = new RadPaneGroup { VerticalAlignment = VerticalAlignment.Top, VerticalContentAlignment = VerticalAlignment.Top };
            this.view.splitContainer.Items.Add(radPaneGroup);
            RadPane radPane = new RadPane
                                          {
                                              Content = createdChartView,
                                              CanUserClose = true,
                                              Title = createdChartView.DisplayName,
                                          };
            RadDocking.SetSerializationTag(radPane, chartConfiguration.Id.ToString());
            RadDocking.SetSerializationTag(radPaneGroup, chartConfiguration.Id.ToString());
 
            radPaneGroup.Items.Add(radPane);
            this.hostedCharts.Add(chartConfiguration.Id, createdChartView);

To explain, chartConfiguration.Id is a Guid which serves as a string tag and hostedCharts is a field of type Dictionary<Guid, ChartView>.
I use this dictionary to get the ChartView when I reload the layout. ChartView is the content I want to reset as the content of the pane.

My element loading event handler looks like this:

private void RadDockingOnElementLoaded(object sender, LayoutSerializationEventArgs e)
        {
            RadPane newPane = e.AffectedElement as RadPane;
            if (newPane != null)
            {
                ChartView chartView = ((ChartHostViewModel)this.DataContext).GetPaneContent(e.AffectedElementSerializationTag);
 
// This entire section is to try to remove the chart from its parent all the way up the visual tree.
                RadPane oldParentPane = (RadPane)chartView.Parent;
                if (oldParentPane != null)
                {
                    RadPaneGroup oldParentGroup = (RadPaneGroup)oldParentPane.Parent;
                    if (oldParentGroup != null)
                    {
                        RadSplitContainer oldSplitContainer = (RadSplitContainer)oldParentGroup.Parent;
 
                        if (oldSplitContainer != null)
                        {
                            oldSplitContainer.Items.Remove(oldParentGroup);
 
                        }
                        oldParentGroup.Items.Remove(oldParentPane);
                    }
                    oldParentPane.Content = null;
                }
 
                newPane.Content = chartView;
                return;
            }
 
// This section is here because the pane groups fill up the entire space if I leave it out (They seem to be aligned to Stretch)
            RadPaneGroup newPaneGroup = e.AffectedElement as RadPaneGroup;
            if (newPaneGroup != null)
            {
                newPaneGroup.VerticalAlignment = VerticalAlignment.Top;
                newPaneGroup.VerticalContentAlignment = VerticalAlignment.Top;
            }
        }

Here's my concern:
Firstly, if I remove the code to try to remove the ChartView from its parent, I get an InvalidOperationException saying to first disconnect the element before adding it to a new one on the line, "newPane.Content = chartView;" . It seems that the entire visual tree is still intact and reloading the screen creates new visual elements and adds these to the Docking component. Is this not memory intensive? Please note that this screen's (my screen, "ChartHostView")'s lifestyle is Transient and may be affecting the way it should work.

Secondly, my pane groups are not being loaded in the state that I saved them in. Why is it necessary for me re-set their Vertical Alignment ?

Please let me know if I am going about this the completely wrong way.
Thank you.
Miroslav Nedyalkov
Telerik team
 answered on 30 Jul 2012
1 answer
77 views
Hi

Can someone help me with the following please

How do I set the foreground color in GridViewCheckBoxColumn in XAML ?

I can't seem to find the appropriate property to set

thanks

Murray
Dimitrina
Telerik team
 answered on 30 Jul 2012
5 answers
1.0K+ views
I have a GridView that displays huge amounts of data. Moreover, columns are generated dynamically depending on the data and columns use custom DataTemplates. That said, GridView really takes some time to draw itself and virtualization feature is crucial for decent performace. However this feature is set to OFF once GridView height is not fixed. Obviously I want my GridView to occupy all available space and change its size when app window is resized. I.e. I want the effect equal to GridView.Height = Auto.

How can I achieve this - that GridView adjusts its size to available free space and still uses virtualization? 
Vlad
Telerik team
 answered on 30 Jul 2012
0 answers
79 views
Hi there

I want to arrange large number of some controls containing labels and buttons to be viewed on a window with the ability of resizing.

Is there any feature to implement what Google did in his image search?
In normal state, the control only shows some picture or labels,
but in mouse-over state it must be zoomed-up and all the contained controls like buttons, gauges, and more...

Thanks
پروژه
Top achievements
Rank 1
 asked on 30 Jul 2012
1 answer
595 views
Hi,

I'm trying to programmatically assign a header template for a column. The header template is similar to the GridViewSelectColumn as it just would have a checkbox in it, but I need the column to be able to bind to a property. I did look at the blog post from Vlad, but it will not work for this particular situation.

Below is the code I have to create a custom template (which works with for an ordinary ListView), but I don't know how to programmatically assign it to the column. I tried setting it to the column.Header property since it's of type object, but that did not work.

FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CheckBox));
factory.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));
factory.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));
factory.SetValue(CheckBox.ToolTipProperty, "(De)Select All");
 
DataTemplate template = new DataTemplate();
template.DataType = typeof(bool);
template.VisualTree = factory;

GridViewCheckBoxColumn column = new GridViewCheckBoxColumn();
column.DataMemberBinding = new Binding(prefix + property.Name);
column.Header = template // <-- this does not work

Thank you,
Tim

Dimitrina
Telerik team
 answered on 30 Jul 2012
2 answers
354 views
I have a GridView that is bound to a QueryableCollectionView. The QueryableCollectionView is constructed from an ObservableCollection, which is populated in code.  (So there's no messing about with LINQ to SQL ORMS, etc.)

I have a command implemented in the ViewModel (bound to a button and to a function key, but that's not important), that needs to check to see if any of the records contained in the grid have certain values in a certain field.

I'd thought I'd be able to do a simple LINQ query on the QueryableCollectionView, but it doesn't seem to work. Even the simplest won't compile.

This:

var customerids =
    from c in customersQueryView
    select c.customerid;

Results in: Instance argument: cannot convert from 'Telerik.Windows.Data.QueryableCollectionView' to 'System.Linq.IQueryable'

This:

var customerids =
    from c in customersQueryView.AsQueryable()
    select c.customerid;

Results in: Cannot convert lambda expression to type 'Telerik.Windows.Data.SelectDescriptorCollection' because it is not a delegate type.

The only workaround I've been able to find is to iterate through all the records with a foreach(), which results in considerably less clear code.
Jeff
Top achievements
Rank 1
 answered on 27 Jul 2012
3 answers
211 views
I've created a CustomGridViewToggleRowDetailsColumn class that descends from GridViewBoundColumnBase.  Its purpose is to display the row details toggle control only if the row in question contains data to be displayed in the row details.

In order to speed up the retrieval of data from my database, I have added a boolean flag to the view model object that is displayed in the RadGridView that indicates whether the object has data for the row details.  This flag is set when the row is retrieved from the database.  However, I do not want to retrieve the data for the row details at the same time.  Rather, I want to wait for the user to click on the button to expand the details and go get the data at that time.  The underlying View Model objects implement INotifyPropertyChanged, so the WPF controls get notification of changes.

The CustomGridViewToggleRowDetailsColumn class has a Click event that I want to program.  When the user clicks on the button, I want the code to check to see if the detail data has been retrieved from the database yet, and if not, to go and get it.

Here's the definition of the CustomGridViewToggleRowDetailsColumn class:

class CustomGridViewToggleRowDetailsColumn : GridViewBoundColumnBase {
  
    public static RoutedEvent ClickEvent =
        EventManager.RegisterRoutedEvent( "Click", RoutingStrategy.Bubble, typeof( ToggleRowDetailsColumnRoutedEventHandler ), typeof( CustomGridViewToggleRowDetailsColumn ) );
  
    public GridViewCell Cell { get; set; }
  
    public event RoutedEventHandler Click {
        add { AddHandler( ClickEvent, value ); }
        remove { RemoveHandler( ClickEvent, value ); }
    }
  
    public override object Header {
        get { return null; }
        set { base.Header = value; }
    }
  
    public GridViewToggleButton ToggleButton { get; set; }
  
    private Binding toggleButtonVisibility;
    public Binding ToggleButtonVisibility {
        get { return toggleButtonVisibility; }
        set { toggleButtonVisibility = value; }
    }
  
    public CustomGridViewToggleRowDetailsColumn() {
        this.EditTriggers = GridViewEditTriggers.None;
    }
  
    public override bool CanFilter() {
        return false;
    }
  
    public override bool CanGroup() {
        return false;
    }
  
    public override bool CanSort() {
        return false;
    }
  
    public override FrameworkElement CreateCellElement( GridViewCell cell, object dataItem ) {
        Cell = cell;
  
        ToggleButton = new GridViewToggleButton { 
            Margin = new System.Windows.Thickness( 3 )
        };
        ToggleButton.Click += new RoutedEventHandler( ToggleButton_Click );
  
        if ( this.DataMemberBinding != null ) {
            ToggleButton.SetBinding( GridViewToggleButton.IsCheckedProperty, this.DataMemberBinding );
        }
  
        if ( ToggleButtonVisibility != null ) {
            ToggleButton.SetBinding( GridViewToggleButton.VisibilityProperty, ToggleButtonVisibility );
        }
  
        GridViewRow row = cell.ParentRow as GridViewRow;
  
        row.SetBinding( GridViewRow.DetailsVisibilityProperty, new Binding( "IsChecked" ) { 
            Source = ToggleButton, 
            Converter = new BooleanToVisibilityConverter(), 
            Mode = BindingMode.TwoWay 
        } );
  
        return ToggleButton;
    }
  
    void ToggleButton_Click( object sender, RoutedEventArgs e ) {
        // Raise our Click event
        RoutedEventArgs newEventArgs = new ToggleRowDetailsColumnRoutedEventArgs( ClickEvent, Cell );
        RaiseEvent( newEventArgs );
    }
}
  
public class ToggleRowDetailsColumnRoutedEventArgs : RoutedEventArgs {
  
    public GridViewCell Cell { get; set; }
  
    public GridViewRow Row {
        get { return Cell.ParentRow as GridViewRow; }
    }
  
    public ToggleRowDetailsColumnRoutedEventArgs( RoutedEvent routedEvent, GridViewCell cell )
        : base( routedEvent ) {
        Cell = cell;
    }
}
  
public delegate void ToggleRowDetailsColumnRoutedEventHandler( object sender, ToggleRowDetailsColumnRoutedEventArgs e );

Here is the Click event handler that I wrote that is called when the user clicks on the toggle button for a row that has details to be displayed:

private void ExpandAlarms_Click( object sender, ToggleRowDetailsColumnRoutedEventArgs e ) {
    ReadViewModel read = e.Row.Item as ReadViewModel;
  
    if ( read.Alarms == null ) {
        read.Alarms = DataInterface.GetAlarmsForRead( read.ID );
    }
  
    e.Handled = true;
}

The problem is that the parameters to the ExpandAlarms_Click method always refer to the same row, no matter which row I click on.  I think there is something wrong, either in the ToggleButton_Click method or in the CreateCellElement method.  But I don't know what the issue could be.  I think I need to save the Cell passed to the CreateCellElement somewhere other than were I'm saving it now, but I'm not sure where that would be.

Please help

Tony
Tony
Top achievements
Rank 1
 answered on 27 Jul 2012
1 answer
169 views
Hello,

I have the following column defined in my xaml code

<
telerik:GridViewMaskedTextBoxColumn Mask="P1" MaskType="Numeric" 
DataMemberBinding="{Binding CurrentAllocationWeight}" 
DisplayIndex="1" IsReadOnly="True" DataFormatString="{}{0:P1}"  
Header="% Of Total" ColumnGroupName="CurrentAllocation"/> 

The bound property is a null-able decimal value. I have no other validation in the code-behind. When I try to enter a value in the cell, I get a validation error: "DecimalConverter cannot convert from System.Double".

How should I fix this, so that the user can enter say, 5.5, and it would display that value as "5.5%" in the cell?

Hasanain
Dimitrina
Telerik team
 answered on 27 Jul 2012
13 answers
637 views
Hi all,

I have two grids. Grid A has data where some of the columns have drop downs. Grid B is used to administrate the lists in the those drop downs.

When a change occurs in Grid B then the values in Grid A are updated using INotifyPropertyChanged. However, I also want validation to kick in (Its possible to delete values from Grid B but Grid A needs to have appropriate values)

For basic cell level validation I have used the cell validating event and that works pretty well. If possible, when Grid B has been updated I would want cell validation to start.

Thanks in advance

Arthur
Arthur
Top achievements
Rank 1
 answered on 27 Jul 2012
5 answers
312 views
Hi.

I'd like to be able to add more manipulation points to a RadDiagramConnection programmatically. Is this possible and how would I go about doing it?

Regards.
Alex Fidanov
Telerik team
 answered on 27 Jul 2012
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
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?