Telerik Forums
UI for WPF Forum
3 answers
152 views
Do you have an example for row visibility ( show/hide ) achieved by utilizing the filtering approach.

I have two buttons for the TreeListView that a user can click that will
- only show first two levels of tree
 - filter out on a column if cell has data.

Thanks

Jessica
Top achievements
Rank 1
 answered on 12 Sep 2011
8 answers
394 views
Hello,  I have a WPF application that utilizes the MVVM pattern.  On my view is a RadGridView defined as

<telerik:RadGridView Name="grdOrders" Grid.Row="1"
                                 AutoGenerateColumns="False"
                                 ItemsSource="{Binding LineItems}"
                                 SelectedItem="{Binding Path=SelectedLineItem}"
                                 IsSynchronizedWithCurrentItem="True"
                                 IsReadOnly="True"
                                 ClipboardCopyMode="Cells"
                                 RowStyleSelector="{StaticResource backorderStyleSelector}"
                                 ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                 ScrollViewer.VerticalScrollBarVisibility="Auto" MouseDoubleClick="grdOrders_MouseDoubleClick" SelectionMode="Extended">
                                 <i:Interaction.Behaviors>
                    <b:MultiSelectBehavior SelectedItems="{Binding Path=SelectedLineItems}" />
                </i:Interaction.Behaviors>
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=GPPONumber}" Header="GP PO Number" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=LineItemId}" Header="Line Item Id" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Quantity}" Header="Quantity" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=PartNumber}" Header="Part Number" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Description}" Header="Description" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=WarehouseCode}" Header="Warehouse" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=WarehouseBin}" Header="Bin Location" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ShippingMethod}" Header="Shipping Method" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=VendorName}" Header="Vendor Name" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Salesrep}" Header="Sales Rep" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=SourcedBy}" Header="Sourced By" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Backordered}" Header="B/O?" />
                </telerik:RadGridView.Columns>
                </telerik:RadGridView>

Corresponding in my ViewModel I have a property

public ObservableCollection<WarehouseLineItemProxy> LineItems
    {
      get
      {
        return lineItems;
      }
      set
      {
        lineItems = value;
        RaisePropertyChanged(() => LineItems);
        ViewOrderInfoCommand.RaiseCanExecuteChanged();
      }
    }

On the View Model is a timer that refreshes the data every 60 seconds

refreshTimer = new DispatcherTimer();
refreshTimer.Interval = TimeSpan.FromSeconds(60);
refreshTimer.Tick += new EventHandler(refreshTimer_Tick);

The tick event and refresh method

/// <summary>
    /// Handles the Tick event of the refreshTimer control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    private void refreshTimer_Tick(object sender, EventArgs e)
    {
      refreshTimer.Stop();
      RefreshLineItems(new object());
      refreshTimer.Start();
    }
 
/// <summary>
    /// Refreshes the line items.
    /// </summary>
    /// <param name="arg">The arg.</param>
    private void RefreshLineItems(object arg)
    {
      if (!worker.IsBusy)
      {
        ShowBusyIndicator = true;
        worker.RunWorkerAsync();
        refreshTimer.Stop();
        refreshTimer.Start();
      }
    }

worker is a BackgroundWorker that allows me to load data asynchronously

/// <summary>
    /// Handles the DoWork event of the worker control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param>
    private void worker_DoWork(object sender, DoWorkEventArgs e)
    {
      e.Result = adapter.LoadWarehouseOrders();
    }
 
/// <summary>
    /// Handles the RunWorkerCompleted event of the worker control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.ComponentModel.RunWorkerCompletedEventArgs"/> instance containing the event data.</param>
    private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
      Dispatcher.CurrentDispatcher.BeginInvoke(new Action<ObservableCollection<WarehouseLineItemProxy>>(this.UpdateGridData), e.Result);
    }   
 
/// <summary>
    /// Updates the grid data.
    /// </summary>
    /// <param name="lineItems">The line items.</param>
    private void UpdateGridData(ObservableCollection<WarehouseLineItemProxy> lineItems)
    {
      LineItems = lineItems;
      ShowBusyIndicator = false;
    }

Occasionally in Production users will get a NullReferenceException at some point when the grid is trying to re-draw.  Here is the stack trace.

at Telerik.Windows.Controls.GridView.Automation.GridViewCellAutomationPeer.GetNameCore() in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Automation\GridViewCellAutomationPeer.cs:line 146
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
   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)
   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, Boolean ignoreSyncCtx)
   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, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   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.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at PartsFinder.Chimera.App.Main() in d:\TeamCityWork\PARTSFinderSlnProd\Chimera\PartsFinder.Chimera\obj\x86\Prod-Warehouse\App.g.cs:line 50

This exception doesn't happen every time, in fact it is very random.  But the users get annoyed when it happens several times during the day.  Does anyone have any ideas?

Thanks
Ivan Ivanov
Telerik team
 answered on 12 Sep 2011
1 answer
141 views
Hi Telerik,
I want to capture the "close" event when the custom scheduler dialog box is closed below (i.e. clicking on the X button), how can I do so?

Thanks, Cheau




        <ControlTemplate x:Key="EditAppointmentTemplate" TargetType="{x:Type telerik:SchedulerDialog}">           

            <Grid VerticalAlignment="Center" Margin="10">

                <Grid.ColumnDefinitions>

                    <ColumnDefinition Width="150"/>

                    <ColumnDefinition/>

                </Grid.ColumnDefinitions>

                <Label Grid.Column="0" Content="Number of Tap Activity" Height="25"/>

                <telerik:RadNumericUpDown Grid.Column="1"  Height="25" Width="50" NumberDecimalDigits="0" ValueFormat="Numeric" HorizontalAlignment="Left"

                                          Value="{Binding Occurrence.Appointment.TapActivityNum, Mode=TwoWay}" />

            </Grid>

        </ControlTemplate>

 

        <Style x:Key="EditAppointmentStyle" TargetType="telerik:SchedulerDialog">

            <Setter Property="Width" Value="250" />

            <Setter Property="Height" Value="100" />

            <Setter Property="IsTabStop" Value="False" />

            <Setter Property="SnapsToDevicePixels" Value="True" />

            <Setter Property="Template" Value="{StaticResource EditAppointmentTemplate}" />

            <Setter Property="HeaderTemplate">

                <Setter.Value>

                    <DataTemplate>

                        <StackPanel Orientation="Horizontal">

                            <TextBlock Text="Number of Tap Activity" />

                        </StackPanel>

                    </DataTemplate>

                </Setter.Value>

            </Setter>

        </Style>


Rosi
Telerik team
 answered on 12 Sep 2011
1 answer
101 views
Hello Telerik Team,

Is it possible to keep the floating panes open (i.e. as is) on the screen when the main window that hosts these panes is minimized?
Currently it minimizes all floating panes. Please let me know.

Regards,
Kumar
Miroslav Nedyalkov
Telerik team
 answered on 12 Sep 2011
6 answers
133 views
Hello,

I am experiencing some annoying effects with the Radchart (however, I don't know if these effects are normal or not).

My user control contains a total of 5 Radcharts, each of them having between 1 and 3 linear series (the total number is 10 series). I am  using a SampleThreshold = 400. For those charts with more than one series I am using a "nested collections" binding schema (as explained in the online documentation).

Each serie has exactly 2880 points that correspond to one point every 30 seconds for an entire day. I make an async call to an WCF service that returns the data for the series. 

The problem is that the charts render in a pretty annoying way. First only some X axis labels are shown, then the series appear but only a piece of them and with an offset respect to their X axis correct position... and so on until the chart is correctly displayed. I am not showing any label or pointmark aside from the X axis and Y axis labels, and animations are disabled. 

I'd like to know if there is any way to prevent the chart to be "pre-painted" in the screen, so that it would only be shown as it is correctly composed. Is there something like a "loading data screen" or similar? 

I am using April 2011 release. 

Thank you in advance, 

Pablo.
Peshito
Telerik team
 answered on 12 Sep 2011
3 answers
128 views
Hello,

Due to the particular needs of our project, we want the user to be able to zoom over the chart's X Axis but without showing any scrollbar. We would do it using the MouseLeftButtonDown and Up belonging to the plot area, calculating the data points and setting a new RangeEnd and RangeStart for the ZoomSettings object. 

However, right now it is only possible to set ZoomSettings to None, Scroll or ScrollAndZoom. Is there any workaround so that zoom can be made (as described above) but hidding the ScrollBar? If so, could you please provide any code sample?

Thank you very much, 

Pablo.

Pablo
Top achievements
Rank 1
 answered on 12 Sep 2011
1 answer
111 views
Hi,

I have a problem since I upgrated from version 2010.3.1314.35 to 2011.2.712.40.
In my scenario I have a "special" TimeRulerItemTemplateSelector which displays a progressbar (status for each day).
With version 2010.3.1314.35 the value-binding (Value="{Binding DateTime, Converter={StaticResource GetDateValue}}") works fine, version 2011.2.712.40 fired the following error:

TwoWay- oder OneWayToSource-Bindungen funktionieren nicht mit der schreibgeschützten Eigenschaft "DateTime" vom Typ "Telerik.Windows.Controls.ScheduleView.TimerRulerItemProxy".

my sources:

            <telerik:TimeRulerItemTemplateSelector.HorizontalTimelineGroupTemplate>
                <DataTemplate>
                    <Grid Height="60">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="20"/>
                            <RowDefinition Height="20"/>
                            <RowDefinition Height="20"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Text="{Binding DateTime, Converter={StaticResource GetWeekDay}}"/>
                        <TextBlock Grid.Row="1" Text="{Binding DateTime, Converter={StaticResource GetDateShort}}"/>
                        <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="2,0,0,0">
                            <ProgressBar Width="40" Minimum="0" Maximum="100" Value="{Binding DateTime, Converter={StaticResource GetDateValue}}"/>
                            <TextBlock Text="{Binding DateTime, Converter={StaticResource GetDateValue}}"/>
                            <TextBlock Text="%"/>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </telerik:TimeRulerItemTemplateSelector.HorizontalTimelineGroupTemplate>

and the GetDateValue Function:

Public Class GetDateValue
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
        If TypeOf value Is DateTime Then
            Dim dt As DateTime = DirectCast(value, DateTime)
            value = 50   'only for demo...
        End If
        Return value

    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Throw New NotImplementedException()
    End Function

End Class

with best regards,
Stefan
Dani
Telerik team
 answered on 12 Sep 2011
1 answer
148 views
Hi Telerik,

I'm using  a RadCombobox in my application and i like to know how i can select item in code behind?
My RadCombobox is bounded thats so:
foreach (ClienteBE _cliente in this.lstCliente)
            {
                tam = _cliente.Nome.Length > tam ?
                    _cliente.Nome.Length :
                    tam;
 
                this.cmbCliente.DisplayMemberPath = "Nome";
                this.cmbCliente.Items.Add(_cliente);
            }

this.lstCliente is a list of objects.

Thanks.
Yana
Telerik team
 answered on 12 Sep 2011
0 answers
267 views

Hi,

I am working with RadGridView, in MVVM WPF application and I need to validate cell compared to other values in binding collection.

I have a object :


public class MyObject
{
    public DateTime DateBegin { get; set;}
    public int Value { get; set;}
}

And if I add a new row in my GridView with existing Date I want to show error message in cell.

I thought to use an ValidationRules in my cell, but i am not sure if i can compared to with others values in binding list. I found some solution, but isn't MVVM compliant :

public void RadGridView1_CellValidating(object sender, GridViewCellValidatingEventArgs e)       {
            bool isValid = true;
            string validationText = "Validation failed. ";
            if(cell.column.uniquename == "mydatecolumn")
           {
            GridViewCell cell = e.Cell;
                    isValid = ValidateDate((datetime) e.NewValue);
                    if (!isValid)
                    {
                        validationText += "You already used that date, mate.";
                    }
           }
}
  
private static bool ValidateDate(datetime newDate)
        {
            // Some linq to see if it's in your collection or not
        }

Thanks

rad
Top achievements
Rank 1
 asked on 12 Sep 2011
2 answers
141 views
Hi,

I need to control the "edit mode" state of the insert row. Let say i have 2 Classes A and B with a "1xN link type" between A and B.
I have in the same screen 2 grids. 1 for type A et 1 for type B. When I add a A in grid 1 I want to be abble of adding Bs in grid2 whitout loosing the "edit mode" of grid 1 insert row.

How coul I do that with the code behind ?


Infologic
Top achievements
Rank 1
 answered on 12 Sep 2011
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?