Telerik Forums
UI for WPF Forum
0 answers
98 views
Hello!

I would like to achieve this result as show in the picture (attachment).
Should I use RadGridView control? Or maybe there is some way to use ListBox instead of GridView?

I have my object's class:

public class Reinforcement
   {
       private string fi;
       private bool spacingMode;
       private int amount;
       private double spacing;
       private bool combine = false;
       private double area;
 
       public Reinforcement()
       {
       }
 
       public Reinforcement(string fi, bool spacingMode, int amount, double spacing, bool combine)
       {
           Fi = fi;
           SpacingMode = spacingMode;
           Amount = amount;
           Spacing = spacing;
           Combine = combine;
       }
 
       public string Fi
       {
           get
           {
               return this.fi;
           }
           set
           {
               this.fi = value;
           }
       }
         // (...) 
}


And ViewModel:

public class ReinforcementViewModel
    {
        private static ObservableCollection<Reinforcement> reinforcementsByAmount;
        private static ObservableCollection<Reinforcement> reinforcementsBySpacing;
 
        public static ObservableCollection<Reinforcement> ReinforcementByAmount
        {
            get
            {
                if (reinforcementsByAmount == null)
                {
                    reinforcementsByAmount = new ObservableCollection<Reinforcement>();
 
                    for (int i = 1; i <= 10; i++)
                    {
                        reinforcementsByAmount.Add(new Reinforcement("10", false, i, 1, false));
                        reinforcementsByAmount.Add(new Reinforcement("12", false, i, 1, false));
 (...)
                    }
                }
 
                return reinforcementsByAmount;
            }
        }


Any ideas or/and tips for me?

I thought that with ListBox I could use panel with specify width and each cell has also specify width. In this way I can wrap items to the next row by calculating width.
 
After that I would like to create an event on cell's click, which return me the Area value. But with this I think I wouldn't have a problem.
Grzesiek
Top achievements
Rank 2
Iron
 asked on 03 Apr 2012
2 answers
137 views
My app is a WPF application designed for use on a touch screen equipped laptop mounted in police cars.  Every control is larger in size and uses a larger font, just to make the application easy to read while driving and easy to interact with.

My main window has a RadTabControl in it.  In one tab I have a Search control I built.  This has a bunch of criteria fields at the top and a RadGridView on the bottom that displays all the rows returned from the datbase that matches the user's criteria.  This is fine and dandy.  Let's call this the Searcher control.

On another tab, I have a new control that I'm building.  This control contains a third party mapping control in it.  All of the data in the database is stamped with geographical coordinates and this new control needs to map each row returned on the map.  Let's call this the Map control.

To make this happen, the Searcher control contains a DependencyProperty called Reads.  This is an ObservableCollection of view model objects corresponding to the data returned by the search.  The Map control also has a DependencyProperty called Reads of the same type.  In the Xaml for my window, I bind the Map control's Reads property to the Searcher Control's Reads property using xaml like this:

<telerik:RadTabControl Name="OperationsTabs"
                SelectionChanged="Tabs_SelectionChanged"
                Visibility="Collapsed">
   
    <telerik:RadTabItem Header="  Search  "
                Name="SearchTab">
        <cs:Searcher Name="SearchControl" />
    </telerik:RadTabItem>
  
    <telerik:RadTabItem Header="Map Results"
                Name="MapResultsTab">
        <cs:MapResults Name="MapResults"
                 Reads="{Binding ElementName=SearchControl, Path=Reads}" />
    </telerik:RadTabItem>
</telerik:RadTabControl>

Here is some code that gets run when the value of the Reads DependencyProperty in the Map control changes:

public void OnReadsChanged( ObservableCollection<ReadViewModel> newValue ) {
    ReadsGrid.ItemsSource = newValue;
}
  
public static void OnReadsChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) {
    MapResults map = (MapResults) d;
    map.OnReadsChanged( (ObservableCollection<ReadViewModel>) e.NewValue );
}

I have seen the code in these methods run in the debugger, so I know that the assignment occurs.

I have added a SelectionChanged event handler to the RadGridView on the Searcher control. Here is what that event does:

private void ReadsGrid_SelectionChanged( object sender, SelectionChangeEventArgs e ) {
    if ( ProcessChange ) {
        MapResultsControl.ProcessChange = false;
        MapResultsControl.ReadsGrid.SelectedItem = ReadsGrid.SelectedItem as ReadViewModel;
        MapResultsControl.ProcessChange = true;
    }
    e.Handled = true;
}

I have also added a SelectionChanged event handler to the RadGridView on the Map control  Here is what that event does:

private void ReadsGrid_SelectionChanged( object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e ) {
    if ( ProcessChange ) {
        SearchControl.ProcessChange = false;
        SearchControl.ReadsGrid.SelectedItem = ReadsGrid.SelectedItem;
        SearchControl.ProcessChange = true;
    }
}

There is code in the MainWindow which assigns the appropriate object references to the MapResultsControl and SearchControl properties.

The idea behind this code is to make sure that the selected item in both RadGridViews stay in synch.  If you change it in one, it changes it in the other.  The ProcessChange flags are there to prevent an infinite recursion of one calling the other.

Now, this works, provided the Map control has been rendered before you try selecting a row in either control.  If you switch to the Map Results tab after finishing the search, the RadGridView is populated with data.  Then selecting a row in either control changes the SelectedItem in the other.

BUT if you select a row in the Searcher control's RadGridView BEFORE you display the Map Results tab, nothing gets selected in the other RadGridView.  This is because the Items property is empty if the RadGridView hasn't been rendered.  I know it is because I've stepped through the code in the debugger and I checked.

So how do I fix this?  What's a good work around for this scenario?

Tony
Tony
Top achievements
Rank 1
 answered on 03 Apr 2012
6 answers
108 views
Hello Telerik.

I am using the GridView and adding content to the HierarchyChildTemplate.  When I add the WebBrowser control I have issues with what appears to be Z order.  I have a Window which contains a RadDocking control.  Here I am using a RadPane extension to utilize an ItemsSource property to allow the dynamic use of RadPane controls.  In the UserControl which is contained in the dynamic RadPane, utilizing a factory pattern, I have the GridView with the HierarchyChildTemplate.  When I create a second RadPane and dock it below the the first the WebBroswer control is not confined to the space held by the HierarchyChildTemplate.  The WebBrowser control is laying over the newly created RadPane.

I thought this may have something to do with your architecture with the docking control when utilzing HTML content.  I did implement the work around described in this post http://www.telerik.com/community/forums/wpf/docking/wpf-frame-control-not-visible-in-floating-window.aspx.  I had the same exact problem in another Window.  However; the resolution here did not resolve the problem I described.  I was not certain if this problem was a result of the GridView or the RadDocking.  With this solution duplicated in my problem it would seem that the problem exists with the GridView and hierarchyChildTemplate and the fact it is in a RadDocking container has no tangible influence.

Could you describe how I can limit the WebBrowser to the HierarchyChildTemplate?

Thanks

Paul
Paul
Top achievements
Rank 1
 answered on 03 Apr 2012
2 answers
82 views
Hello,
I've developed a quite huge WPF application, with RadGridview's context menu representing the operation a user can do on a certain entity, now I've been asked to add the feature of allowing to show/remove columns for user personalization... I've tried on a mockup project the demo code on Telerik's demo -> RadGridView -> Header Context Menu ... this works fine if I've got a single context menu, if I've defined my own (the application has around 60 different context menu) the headermenu isn't shown... what can I do to have both living on my gridview?
I've tried following the code at 
http://www.telerik.com/help/silverlight/radcontextmenu-how-to-use-radcontextmenu-with-radgridview.html 

but it doesn't work fine with the demo implementation...any suggestion?
Thanks
Paolo
Michele
Top achievements
Rank 2
 answered on 03 Apr 2012
1 answer
133 views
I have disabled the context menu for a RadRichTextBox via Xaml like IsContextMenuEnabled="False".
Still a context menu is shown, it look's like a part of the ribbon to set font properties.
You can choose font, background and foreground color, bold, italic etc.
I would like to get rid of this context menu as wel, is this possible and so yes how?

Mike
Telerik team
 answered on 03 Apr 2012
1 answer
86 views
Hy,

I've got a question.
If i have 20 TileViewItem in my TileView as an Example, a Scrollbar automaticaly appear.
Is it Possible to Activate the Pan Feature to this Scrollbar. I need that Feature for a Tablet App

Thank

Alfred
SPARE GmbH
Top achievements
Rank 2
 answered on 03 Apr 2012
2 answers
148 views
Hello telerik support,

this morning i switched from 2011.3.1220.40 to Q1 2012 SP1 and since then the synchronization between GridView
and DataForm rises an exception (Parameter count mismatch).

The first attempt was to switch from OberservableCollection to ICollectionView but that's not the problem.
My project references the sp1 files, but could it be that the versions are mixed during execution?

regards
Chris

Stacktrace:
Parameter count mismatch.

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Telerik.Windows.Data.ItemPropertyInfoExtensions.GetValue(ItemPropertyInfo itemProperty, Object item)
   at Telerik.Windows.Controls.RadDataForm.PopulatePropertiesInitialValues(Object currentItem)
   at Telerik.Windows.Controls.RadDataForm.OnCurrentItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.RadDataForm.set_CurrentItem(Object value)
   at Telerik.Windows.Controls.RadDataForm.OnItemsCurrentChanged(Object sender, EventArgs e)
   at Telerik.Windows.Data.DataItemCollection.OnCurrentChanged(EventArgs e)
   at Telerik.Windows.Data.DataItemCollection.OnCollectionViewCurrentChanged(Object sender, EventArgs args)
   at Telerik.Windows.Data.Listener`2.ReceiveWeakEvent(Object sender, TArgs args)
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.OnCurrentChanged(EventArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.MoveCurrentToPositionCore(Int32 position)
   at Telerik.Windows.Data.QueryableCollectionView.MoveCurrentToPosition(Int32 position)
   at Telerik.Windows.Data.QueryableCollectionView.MoveCurrentTo(Object item)
   at Telerik.Windows.Data.DataItemCollection.MoveCurrentTo(Object item)
   at Telerik.Windows.Data.DataItemCollection.UpdateCurrentItemFromSourceCollection()
   at Telerik.Windows.Data.DataItemCollection.OnSourceCollectionViewCurrentChanged(Object sender, EventArgs args)
   at Telerik.Windows.Data.Listener`2.ReceiveWeakEvent(Object sender, TArgs args)
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Data.CollectionView.OnCurrentChanged()
   at System.Windows.Data.ListCollectionView.MoveCurrentToPosition(Int32 position)
   at System.Windows.Data.CollectionView.MoveCurrentTo(Object item)
   at Telerik.Windows.Data.DataItemCollection.UpdateSourceCollectionCurrentItem()
   at Telerik.Windows.Data.DataItemCollection.OnCollectionViewCurrentChanged(Object sender, EventArgs args)
   at Telerik.Windows.Data.Listener`2.ReceiveWeakEvent(Object sender, TArgs args)
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.OnCurrentChanged(EventArgs args)
   at Telerik.Windows.Data.QueryableCollectionView.MoveCurrentToPositionCore(Int32 position)
   at Telerik.Windows.Data.QueryableCollectionView.MoveCurrentToPosition(Int32 position)
   at Telerik.Windows.Data.QueryableCollectionView.MoveCurrentTo(Object item)
   at Telerik.Windows.Data.DataItemCollection.MoveCurrentTo(Object item)
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.SyncCurrentWithSelected()
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.TrySyncCurrentWithSelected()
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.RaiseSelectionChangedAndSyncCurrentWithSelectedIfNeeded(ItemSelectionChange selectionChange)
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.EndAllowedSelection(ItemSelectionChange selectionChange)
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.EndPendingSelection(ItemSelectionChange pendingSelection)
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.EndSelection()
   at Telerik.Windows.Data.Selection.ItemSelectionHandler.PerformSelection(Object item, SelectionModificationOptions options)
   at Telerik.Windows.Controls.GridView.Selection.CompositeSelectionHandler.PerformRowSelection(Object dataItem, SelectionModificationOptions modificationOptions)
   at Telerik.Windows.Controls.GridView.Selection.CellAndRowSelectionDispatcher.HandleSelectionForValidCellInput(GridViewCell cell, SelectionModificationOptions allowedModifications)
   at Telerik.Windows.Controls.GridView.Selection.CellAndRowSelectionDispatcher.HandleSelectionForCellInput(GridViewCell cell, SelectionModificationOptions allowedModifications)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.HandleMouseDownSelection(GridViewCell cell, Boolean allowDrag, Point mousePosition)
   at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   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.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Hubert
Top achievements
Rank 1
 answered on 03 Apr 2012
3 answers
200 views
Hi,
I have a problem when using commom column header, I got a null reference exception,
I'm using pdb files to debug telerik gridviiew dll and exception occurs in CommonHeaderPresenter Class and ArrangeLowestHeaders() method.

private void ArrangeLowestHeaders()
        {
 
 
            string lastGroupName = String.Empty;
            CommonColumnHeader lastCommonHeader = null;
            int span = 0;
 
            List<CommonColumnHeader> headers = new List<CommonColumnHeader>();
            for (int i = 0; i < this.OrderedColumns.Count; i++)
            {
                string groupName = this.OrderedColumns[i].ColumnGroupName;
 
                if (lastGroupName != groupName)
                {
                    lastGroupName = groupName;
                    span = 0;
 
                    CommonColumnHeader commonHeader = CreateCommonHeader();
                    this.CommonHeadersGrid.Children.Add(commonHeader);
                    var group = FindGroupByName(groupName, this.ColumnGroups);
                    commonHeader.ColumnGroup = group;
                    commonHeader.Content = CommonHeaderPresenter.GetContent(group);//TODO  this should happen in the header itself.
                    SetTemplateAndStyle(commonHeader, group);
                    commonHeader.SetValue(Grid.ColumnProperty, i);
                    commonHeader.SetValue(Grid.RowProperty, this.RowCount - 1);
                    commonHeader.HorizontalAlignment = HorizontalAlignment.Stretch;
                    headers.Add(commonHeader);
                    lastCommonHeader = commonHeader;
                }
 
                span++;
                lastCommonHeader.SetValue(Grid.ColumnSpanProperty, span);
                if (gridView.FrozenColumnCount > 0)
                {
                    SelectiveScrollingGrid.SetSelectiveScrollingOrientation(lastCommonHeader, SelectiveScrollingOrientation.Vertical);
                }
            }
 
            if (RowCount > 1)
            {
                ArrangeHeadersAtRow(this.RowCount - 2, headers);
            }
        }


To get this bug , set  ColumnGroupName property of the first column of your grid to string.empty or set the first groupName to string empty.
Because lastGroupName = groupName = string.empty,
lastCommonHeader is not initialized and you have a null reference exception at line 142.



										
Pavel Pavlov
Telerik team
 answered on 03 Apr 2012
0 answers
280 views
XAML
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10" HorizontalAlignment="Center">
    <telerik:RadButton  x:Name="btStartLog" Content="{Binding startStopbuttonText}" IsEnabled="{Binding isEnableTextBox}"
        Command="{Binding startStopLogConfigCommand}" Margin="10" Width="150" Height="40" />
 </StackPanel>
<telerik:RadGridView x:Name="RadGridView1">
    <telerik:GridViewDataColumn Header="To File">
        <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                        <CheckBox HorizontalAlignment="Left" VerticalAlignment="Center" IsChecked="{Binding IsOnFile}" />
                    </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
            <telerik:GridViewColumn.CellStyle>
            <Style TargetType="telerik:GridViewCell">
                <Setter Property="IsEnabled" Value="{Binding ElementName=btStartLog, Path=IsEnabled}" />
            </Style>
        </telerik:GridViewColumn.CellStyle>
    </telerik:GridViewDataColumn>
</telerik:RadGridView>


I would like to get IsEnabled from Button to set property of Checkbox in Radgridview but when i use code above it not working
please help.
ipOPza
Top achievements
Rank 2
 asked on 03 Apr 2012
1 answer
128 views
I have a screen that contains a radgrid on it, when the user clicks to add a new record and they enter the new info I do a check to see if it is a possible duplicate.  If it is I want to display a Confirm message box that will inform them that it is a possible dup, but allow them to add the record.
I am currently using a messagebox but would like to use a radwindow, but when I add an even hadler I do not see a way to pass the data to the new method.  Or should I try and read the active row of the grid after the confrim?

public void UpdateTransaction(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
       {
           EditData ed = new EditData();
           FundTransaction trans = (FundTransaction)e.NewData;
 
           if (trans.FundID != null && trans.TickerID != null)           {
               string result = ed.EditFundTransaction(trans.TransactionID, trans.FundID); 
               if (result != "")
               {
                   if (MessageBox.Show(result, "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                   {
                       ImportData id = new ImportData();
                       id.AddTransaction(trans.FundID, trans.TickerID);                   }
 
                  }
           }
       }
Ivo
Telerik team
 answered on 03 Apr 2012
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?