Telerik Forums
UI for WPF Forum
5 answers
549 views

Hello,

I trying to move rows up or down depending on user selection from the Context Menu.

And for some reason (still trying to figure out), the IndexOf is returning -1.

Below are my XAML code =>

             <telerik:RadGridView x:Name="gridView1" Grid.Row ="1" AutoGenerateColumns="False" Margin="0,5,0,10" FontSize="12" Deleted="OnDeletedIO"

                                                               Deleting="OnDeletingIO" telerik:StyleManager.Theme="Summer" DataGridCell.GotFocus="DataGrid_CellGotFocus">    
                        <telerik:RadGridView.ContextMenu>
                            <ContextMenu >
                                <MenuItem Header="MoveUp"  Click="MoveUp_click"/>
                            </ContextMenu>
                        </telerik:RadGridView.ContextMenu>
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding name}" Header="Name" IsReadOnly="False"/>
                            <telerik:GridViewComboBoxColumn x:Name="ComboGroup" DataMemberBinding="{Binding group}"  Header="Group"/>
                            <telerik:GridViewComboBoxColumn x:Name="ComboRTU" DataMemberBinding="{Binding rtu}"  Header="RTUs"/>
                            <telerik:GridViewComboBoxColumn x:Name="ComboOP" DataMemberBinding="{Binding op}"  Header="Operation"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding addr}" Header="Address"/>
                            <telerik:GridViewComboBoxColumn x:Name="ComboTypes2" DataMemberBinding="{Binding dataType}"  Header="Data Type"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding swapByte}" Header="Byte&#x0a;Swapping"
                            IsReadOnly="True">                                
                           </telerik:GridViewDataColumn>
                        </telerik:RadGridView.Columns>
                  </telerik:RadGridView>

 

C# code =>

namespace MBM_WPF
{    
    public partial class MainWindow : Window
    {

        MBM mbm1 ;
        MBM_view mbmView;        
 
        public MainWindow(string path)
        {
            StyleManager.ApplicationTheme = new SummerTheme();
            InitializeComponent();
            logger = LogManager.GetLogger("Instruct.MBM_Main");
            Configpath = path;
            
            //Populating ItemsSource here
            
            catch 
            {
                mbm1 = new MBM();
                mbmView = new MBM_view(mbm1, OnSettingChanged);
                BindMyData();
            }
        }

private void MoveUp_click(object sender, RoutedEventArgs e)
        {            
            //Get the clicked MenuItem
            var menuItem = (MenuItem)sender;
            
            //Get the ContextMenu to which the menuItem belongs
            var contextMenu = (ContextMenu)menuItem.Parent;            

            //Find the placementTarget
            var item = (RadGridView)contextMenu.PlacementTarget;
            
            int index = this.gridView1.Items.IndexOf(item.SelectedItem);

            this.gridView1.Items.Remove(item.SelectedItem);
           
            this.gridView1.Items.Insert(index - 1, item.SelectedItem);
            item.SelectedItem = item; 

            mbmView.IoListCleanUp();
            mbmView.AlarmsCleanUp();    

        }
     }
}

Please help.

Thank you!!

 

Regards,

Darren

 

Martin Ivanov
Telerik team
 answered on 31 Jul 2020
4 answers
392 views

 

I am attempting to set default values to a Telerik RadDataForm in the InitializingNewItem Event. RadDataForm is linked to a RadGridView as the Source, the intention is that when an item is selected in the grid and this is present in the dataform, clicking the Add New Item will pre-populate the dataform with some key data from the previously selected item.

You (Telerik) state: "Occurs when a new item is being added but after the AddingNewItem event. You can use this to set initial values for the initialized objects by passing an instance to the InitializingNewItemEventArgs' DataItem property."

However simply using:

private void RadDataForm_InitializingNewItem(object sender, Telerik.Windows.Controls.Data.DataForm.InitializingNewItemEventArgs e)

{

    RadDataForm d = sender as RadDataForm;

    // Copy and set all data to existing record

    e.DataItem = d.CurrentItem as GetParts_Result;

    // Change some data to another default value

    (GetParts_Result)e.DataItem).Name = "New Name";

}

 

This causes a ArgumentNullException error for 'Parameter name: Key'?

Is there a working example of this event being utilised available...

 

 

Vladimir Stoyanov
Telerik team
 answered on 31 Jul 2020
4 answers
1.0K+ views

Hi

Is there a way to Preview the SelectionChanged, and also stop the Navigation.

 

Something like " PreviewSelectionChanged" on RadTabControl, where I can set "Handled=true" to stop navigation.

 

/Peter

 

 

Randy
Top achievements
Rank 1
Veteran
 answered on 31 Jul 2020
4 answers
357 views

I have a ViewModel object with multiple properties I want to plot (such as Value1 and Value2 in DualSample below).  I currently have this working with a SeriesProvider that includes a different SeriesDescriptor and ValueBinding for each property, but using the same ItemsSourcePath.

 

However, I now have some data sets to plot that have a different sample arrangement (such as only having Value1 in SingleSample, and missing Value2).  If I try to use the existing SeriesProvider definition, I get an exception because the SensorValue2Binding doesn't work since the sample is a different type.  I was going to change this to use a SeriesDescriptorSelector, but I don't see how to get multiple series from a single ViewModel  object as before.  The only solution I see is to create separate lists for each property I want to plot, but I'd rather avoid that is I can, mostly to help save on memory usage. 

ViewModel definition:

public interface ISample
{
}
 
// Would like to plot this on the same chart as DualSample
public class SingleSample : ISample
{
    public Double Value1;
    public DateTime Timestamp;
}
 
// This is currently working
public class DualSample : ISample
{
    public Double Value1;
    public Double Value2;
    public DateTime Timestamp;
}
 
public class Sensor
{
    // A Sensor might have a set of DualSample values, or a set of SingleSample values, but not both.
    public ObservableCollection<ISample> SensorData;
}

 

Currently working solution for DualSample only:

<!-- Existing solution that working with DualSample only -->
<telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding SensorList}">
        <!-- When SensorData includes DualSample values, both series descriptors below are used,
        so I get series for both Value1 and Value2 -->
        <telerik:ChartSeriesProvider.SeriesDescriptors>
            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="SensorData">
                <telerik:CategoricalSeriesDescriptor.Style>
                    <Style TargetType="telerik:LineSeries"
                           BasedOn="{StaticResource {x:Type telerik:LineSeries}}">
                        <Setter Property="ValueBinding"
                                Value="{StaticResource SensorValue1Binding}"/>
                        <Setter Property="VerticalAxis"
                                Value="{StaticResource Value1Axis}"/>                                               
                    </Style>
                </telerik:CategoricalSeriesDescriptor.Style>
            </telerik:CategoricalSeriesDescriptor>
 
            <!-- If I have a SensorData collection of SingleSamples, the SensorValue2Binding values
            and the plot crashes with the following ArgumentException:
            "The value Telerik.Windows.Controls.ChartView.LineSeries is not of type
            Telerik.Windows.Controls.ChartView.CartesianSeries and cannot be used in this generic collection"
            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="SensorData">
                <telerik:CategoricalSeriesDescriptor.Style>
                    <Style TargetType="telerik:LineSeries"
                           BasedOn="{StaticResource {x:Type telerik:LineSeries}}">
                        <Setter Property="ValueBinding"
                                Value="{StaticResource SensorValue2Binding}"/>
                        <Setter Property="VerticalAxis"
                                Value="{StaticResource Value2Axis}"/>
                    </Style>
                </telerik:CategoricalSeriesDescriptor.Style>
            </telerik:CategoricalSeriesDescriptor>
        </telerik:ChartSeriesProvider.SeriesDescriptors>
    </telerik:ChartSeriesProvider>
</telerik:RadCartesianChart.SeriesProvider>

 

 

Attempted solution to work with both DualSample and SingleSample:

<!-- Attempted solution that I would like to work with both DualSample and SingleSample data sets -->
<telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding SensorList}">
        <telerik:ChartSeriesProvider.SeriesDescriptorSelector>
            <local:MySeriesDescriptorSelector>
                <local:MySeriesDescriptorSelector.Value1SeriesDescriptor>
                    <telerik:CategoricalSeriesDescriptor ItemsSourcePath="SensorData">
                        <telerik:CategoricalSeriesDescriptor.Style>
                            <Style TargetType="telerik:LineSeries"
                                   BasedOn="{StaticResource {x:Type telerik:LineSeries}}">
                                <Setter Property="ValueBinding"
                                        Value="{StaticResource SensorValue1Binding}"/>
                                <Setter Property="VerticalAxis"
                                        Value="{StaticResource Value1Axis}"/>
                            </Style>
                        </telerik:CategoricalSeriesDescriptor.Style>
                    </telerik:CategoricalSeriesDescriptor>
                </local:MySeriesDescriptorSelector.Value1SeriesDescriptor>
                <local:MySeriesDescriptorSelector.Value2SeriesDescriptor>
                    <telerik:CategoricalSeriesDescriptor ItemsSourcePath="SensorData">
                        <telerik:CategoricalSeriesDescriptor.Style>
                            <Style TargetType="telerik:LineSeries"
                                   BasedOn="{StaticResource {x:Type telerik:LineSeries}}">
                                <Setter Property="ValueBinding"
                                        Value="{StaticResource SensorValue2Binding}"/>
                                <Setter Property="VerticalAxis"
                                        Value="{StaticResource Value2Axis}"/>
                            </Style>
                        </telerik:CategoricalSeriesDescriptor.Style>
                    </telerik:CategoricalSeriesDescriptor>
                </local:MySeriesDescriptorSelector.Value2SeriesDescriptor>
            </local:MySeriesDescriptorSelector>
        </telerik:ChartSeriesProvider.SeriesDescriptorSelector>
    </telerik:ChartSeriesProvider>
</telerik:RadCartesianChart.SeriesProvider>

 

Any suggestions?  Or is my only option to extract my Value1 and Value2 properties into separate lists?

Brandon
Top achievements
Rank 1
Veteran
 answered on 30 Jul 2020
1 answer
338 views

https://marketplace.visualstudio.com/items?itemName=vs-publisher-443.TelerikUIforWPF

vs

https://marketplace.visualstudio.com/items?itemName=TelerikInc.TelerikWPFVSExtensions

Yana
Telerik team
 answered on 30 Jul 2020
1 answer
359 views

I had read this: https://docs.telerik.com/devtools/wpf/getting-started/installation/installation-installing-from-nuget-wpf

I prefered to install NuGet package rather than install a big setup(TelerikUIForWpfSetup.exe).

So could I only install NuGet package to use the full features of UI for WPF?

Nikola
Telerik team
 answered on 30 Jul 2020
1 answer
169 views
Is it possible, and if yes how, to make IDataErrorInfo validation not mandatory? 

My issue is that user cannot leave the cell when data in it is not valid. I would like to have all the suff like border, outline etc but to be able to leave the cell or the row.
Martin Ivanov
Telerik team
 answered on 30 Jul 2020
3 answers
177 views

Hello,

 

I was wandering if it was possible to change the style of an appointment that starts on one day and ends the next day in a Month View. For exemple, a shift that begins at 22pm and ends at 6am. When I try to do it it just streches the appointment across both days, but I don't want that is there a way to change this?

 

There's a picture of what I would want to see.

 

Thanks

Vladimir Stoyanov
Telerik team
 answered on 30 Jul 2020
2 answers
381 views
Hi,

I'm having some trouble using RadControls_for_WPF_2009_2_0813_TRIAL. I have used in a project RadWindow for WPF. "Sometimes" when I close a window the InvalidOperationException is thrown. I'm hoping to find help here, because for the moment I'm using the trial version of the controls, trying to demonstrate that this is a fine acquisition. Here is part of my stack trace:

Startup URI: ....xbap
Application Identity: file:///....xbap

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Max(IEnumerable`1 source)
   at Telerik.Windows.Controls.RadWindowPopup.WindowPopupAdornerFactory.WindowPopupAdornerImpl.BringToFront()
   at Telerik.Windows.Controls.RadWindowManager.BringToFront(RadWindow window)
   at Telerik.Windows.Controls.RadWindow.<BringToFront>b__3()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(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, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.StartDispatcherInBrowser(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(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, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

-----------------------

Thanks !!
Mehrdad
Top achievements
Rank 1
 answered on 29 Jul 2020
3 answers
554 views

I have a RedGridView with one of the columns editable. When the user enters a new value in a cell of that column and then hits enter, the

next row gets focused. I dont want that to happen. I just want the cell to lose its focus.

 

Dilyan Traykov
Telerik team
 answered on 29 Jul 2020
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?