Telerik Forums
UI for WPF Forum
1 answer
101 views
Hello,
I am new to telerik controls. today i try to show a bar chart with data binding, but always unable to see the bars, only empty chart. below is the xaml and view model. thanks in advance for your help!

Thank you,
Alex

<UserControl
    xmlns:MHSVisualBoard_ViewModels="clr-namespace:MHSVisualBoard.ViewModels"
    mc:Ignorable="d"
    x:Class="MHSVisualBoard.MissionsByForklift"
    x:Name="UserControl"
    d:DesignWidth="582" d:DesignHeight="400" MaxWidth="550" MaxHeight="300" Width="550" Height="Auto">
 
    <Grid x:Name="LayoutRoot">
        <UniformGrid Margin="0" Rows="2" Columns="1">
            <telerik:RadChart x:Name="charMissionsTrend" Content="" Style="{DynamicResource RadChartStyle}" OverridesDefaultStyle="True"/>
            <telerik:RadChart x:Name="chartMissionAssignedVsFinished" Content="" Style="{DynamicResource RadChartStyle}" OverridesDefaultStyle="True" ItemsSource="{Binding Data, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                <telerik:RadChart.DataContext>
                    <MHSVisualBoard_ViewModels:MissionsByForkliftViewModel>
                        <MHSVisualBoard_ViewModels:MissionsByForkliftViewModel.Data>
                            <MHSVisualBoard_ViewModels:ForkliftMissions AssignedMissions="12" FinishedMissions="3" ForkliftId="E1"/>
                            <MHSVisualBoard_ViewModels:ForkliftMissions AssignedMissions="15" FinishedMissions="9" ForkliftId="E2"/>
                        </MHSVisualBoard_ViewModels:MissionsByForkliftViewModel.Data>
                    </MHSVisualBoard_ViewModels:MissionsByForkliftViewModel>
                </telerik:RadChart.DataContext>
                <telerik:RadChart.SeriesMappings>
                    <telerik:SeriesMapping SeriesDefinition="{DynamicResource ISeriesDefinitionBarOne}">
                        <telerik:ItemMapping DataPointMember="XCategory" FieldName="{Binding Data[0].ForkliftId}"/>
                        <telerik:ItemMapping FieldName="{Binding Data[0].AssignedMissions}" DataPointMember="YValue"/>
                    </telerik:SeriesMapping>
                </telerik:RadChart.SeriesMappings>
            </telerik:RadChart>
        </UniformGrid>
    </Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Controls;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace MHSVisualBoard.ViewModels
{
    public class MissionsByForkliftViewModel : ViewModelBase
    {
        public MissionsByForkliftViewModel()
        {
            _data = new ObservableCollection<ForkliftMissions>();
        }
 
        public ObservableCollection<ForkliftMissions> Data
        {
            get
            {
                return _data;
            }
            set
            {
                if (value != _data)
                {
                    _data = value;
                    this.OnPropertyChanged("Data");
                }
            }
        }
 
        private ObservableCollection<ForkliftMissions> _data;
    }
 
    public class ForkliftMissions : INotifyPropertyChanged
    {
        public ForkliftMissions()
        {
 
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        public string ForkliftId
        {
            get
            {
                return _forkliftId;
            }
            set
            {
                _forkliftId = value;
            }
        }
 
        public int AssignedMissions
        {
            get
            {
                return _assignedMissions;
            }
            set
            {
                if (value != _assignedMissions)
                {
                    _assignedMissions = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AssignedMissions"));
                }
            }
        }
 
        public int FinishedMissions
        {
            get
            {
                return _finishedMissions;
            }
            set
            {
                if (value != _finishedMissions)
                {
                    _finishedMissions = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("FinishedMissions"));
                }
            }
        }
 
        private string _forkliftId;
        private int _finishedMissions;
        private int _assignedMissions;
    }
}
Petar Marchev
Telerik team
 answered on 21 Aug 2012
1 answer
119 views
Hello ,

How do I know that up/down button has pressed. I tried it using valueChanged event but I could not figure out that the value has changed by either from the Textbox or from the up/down buttons.

Thanks in Advance.

Regards,
KK

Ivo
Telerik team
 answered on 21 Aug 2012
2 answers
65 views
I use to display RadCartesianChart Candlestick for software exchange.

when I board units on the X axis DateTimeContinuousAxis MajorStepUnit = "Hour" or minutes I would like to define the hours of closure of stock exchanges
  and for the weekend, so it does not appear on the graph as the data is empty periods for its

Thanks.
Nikolay
Telerik team
 answered on 21 Aug 2012
1 answer
156 views
Hi,

I have the following code:

    dim objectControl as new myCustomControl  'This control have two buttons "OK" and "CANCEL"

            With radObjectWindow
                
                .Header = "Some text...."
                .WindowStartupLocation = WindowStartupLocation.CenterScreen
                .ResizeMode = ResizeMode.NoResize
                
                .Owner = Owner '(Window.GetWindow(me))
                .Content = objectControl

                .ShowDialog()

            End With

This code works fine, the modal window have a behavior expected, but how capture the "OK" or "CANCEL" click action....from buttons into a RadWindow....into a CustomControl.....

In fact, I have understood that the radwindow is asynchronous, then how to make action buttons in the custom control affect the program flow of this modal window .....

Thanks....

Stefan
Top achievements
Rank 1
 answered on 20 Aug 2012
0 answers
60 views

Hi, I am not sure that's true cause I Use this WCF : 

Interface : 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfServiceHotel
{
[ServiceContract]
public interface IServiceHotel
{

[OperationContract]
List<UserDetail> GetUserDetail(int id);

[OperationContract]
String InsertUserDetail(UserDetail userinfo);

[OperationContract]
List<UserDetail> GetAllHotel();

}

[DataContract]
public class UserDetail
{
int _id = 0;
string _Nom = String.Empty;
string _Ville = String.Empty;

[DataMember]
public int Id
{
get { return _id; }
/*private*/ set { _id = value; }
}

[DataMember]
public string Nom
{
get { return _Nom; }
set { _Nom = value; }

}

[DataMember]
public string Ville
{
get { return _Ville; }
set { _Ville = value; }
}

}

}

Class : 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace WcfServiceHotel
{
public class ServiceHotel2 : IServiceHotel
{
SqlConnection con = new SqlConnection("Data Source=.\\SqlEXPRESS;Initial Catalog=GestionHotel;Integrated Security=True");

public List<UserDetail> GetUserDetail(int id)
{
List<UserDetail> userdetail = new List<UserDetail>();
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from HotelIdentite where Id = @id", con);
// SqlCommand cmd = new SqlCommand("Select * from HotelIdentite where Id like '%'+@id+'%'", con);
cmd.Parameters.AddWithValue("@id", id);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
UserDetail userInfo = new UserDetail();
userInfo.Nom = dt.Rows[i]["Nom"].ToString();
userInfo.Ville = dt.Rows[i]["Ville"].ToString();
userdetail.Add(userInfo);
}
}
con.Close();
}
return userdetail;
}

public List<UserDetail> GetAllHotel()
{
List<UserDetail> usd = new List<UserDetail>();
{
con.Open();
SqlCommand cmd = new SqlCommand("Select Id,Nom,Ville From HotelIdentite", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
UserDetail ud = new UserDetail();
ud.Id = int.Parse(dt.Rows[i]["Id"].ToString());
ud.Nom = dt.Rows[i]["Nom"].ToString();
ud.Ville = dt.Rows[i]["Ville"].ToString();
usd.Add(ud);
}
}
con.Close();
}
return usd;
}

public string InsertUserDetail(UserDetail userinfo)
{
string strMessage = string.Empty;
con.Open();
SqlCommand cmd = new SqlCommand("Insert into HotelIdentite (Nom,Ville) Values (@Nom,@Ville)", con);
cmd.Parameters.AddWithValue("@Nom", userinfo.Nom);
cmd.Parameters.AddWithValue("@Ville", userinfo.Ville);
int result = cmd.ExecuteNonQuery();
if (result == 1)
{
strMessage = userinfo.Id + " Details inserted successfully";
}
else
{
strMessage = userinfo.Id + " Details not inserted successfully";
}
con.Close();
return strMessage;
}

//public override string ToString(int index, [OptionalField] int id,[OptionalField] UserDetail userinfo)
//{
// string result;
// switch (index)
// {
// case 1:
// GetUserDetail(id);
// break; 
// case 2 :
// InsertUserDetail(userinfo);
// break;
// }

// return result;
//}
}
}

So for implemente I use two client : a Windows phone and WPF

for the WPF client the GetAllHotelCompletedEventArgs is missing and the same thing for the others methods and all the methods are not VOID :

Help me please 
Tahnk you 

Berrabah
Top achievements
Rank 1
 asked on 20 Aug 2012
2 answers
486 views
Hi everyone,
 
 we're moving from WinForms to WPF.

Our old WinForms-Application had a third-party grid which was able to group columns and freeze them on the left and right.

According to several general WPF forums (see also Telerik-GridView threads: http://www.telerik.com/community/forums/silverlight/gridview/how-to-lock-the-columns.aspx
 http://www.telerik.com/community/forums/silverlight/gridview/freezing-last-column.aspx ) freezing columns on the right seems to be a missing functionality in all(?) WPF datagrids.
 
Surely, we don't want our customers to miss that functionality, so we have written a custom control which contains two datagrids (System.Windows.Controls.DataGrid, one to the left and one to the right).
Both datagrids share the same itemssource and actions like sorting, vertical scrolling, selecting, columns/row resizing, mouse over events etc. were "synchronised".
To have a column frozen to the left, the column is "moved" (= visibilty switch) to the left datagrid, its display index is set to "FrozenColumnCount + 1" and the FrozenColumnCount is increased.
To have a column frozen to the right, the column is moved to the right datagrid where all columns were frozen.(*)

This custom control delivered a grid which was able to freeze columns on the left and the right.
Still missing was that grouping function which the old WinForms grid additionally had.

We decided to use the Telerik GridView which should replace the datagrid in our custom control.

Same procedure as mentioned...additionally we had to "synchronise" the grouping and the expanding/collapsing of each GridViewGroupRow.
Last-mentioned seems to be an unmanageable hurdle.
The "synchronising" of the grouping enables that the same GridViewGroupRows are available in both datagrids.
If a GridViewGroupRow is expanded or collapsed, we programmatically look for the GridViewGroupRow with the same group key (and parent group keys) in the other GridView and set the "IsExpanded" property to the according value. At first glance this seemed to work, but unfortunately sometimes the GridViewGroupRow stayed collapsed/expanded in the UI.
According to the debugger the property is also correctly set, the UI is not blocked.

We have no explanation for this and don't expect them here. This thread should only share our attempt to create a grid with left and right freezing and grouping functionality, in hope to gain some other valuable programmers experience/information concerning this matter and answers to following questions:

Has anyone successfully created a grid which has draggable grouping and left and right freezing functionality?

Is Telerik planning to extend the GridView with 'freezing right/last columns' functionality?

Answers why the GridViewGroupRow does sometimes not collapse/expand if this is done programmatically
(Note: Virtualization has been disabled! And even if not, the according GridViewGroupRow is available programmatically and visible in UI) ?



--------------------------------------------------------------------------
Notes only for those interesting which like to implement it that way:
(*) Left datagrid should be in a column definition with GridLength.Star, right datagrid should be in a column definition with GridLength.Auto.
Width of right datagrid must be calculated (sum each visible column width) since datagrid doesn't auto resize if columns are narrowed.
Dimitrina
Telerik team
 answered on 20 Aug 2012
3 answers
349 views
Is it possible to override the default behavior of RadGridView and display combobox with "Yes" and "No" instead of checkboxes for boolean columns?
Yoan
Telerik team
 answered on 20 Aug 2012
2 answers
211 views

I'm trying to accomplish a scenario and I'm failing to find a decent info about your drag and drop implementation. Help is seriously lacking info and have mixed RadDragAndDropManager and DragDropManager content which doesn't helps at all.

My scenario:

 - Read only list (displayed in a RadListBox)

 - Another RadListBox that should be populated with items from first one

 - A Converter that converts items from one format to another

So I would like that items from first list aren't removed. In my current implementation I'm receiving an exception when dropping items on second list telling me that ItemsSource from the read-only listbox cannot be modified.

Any hints on how to accomplish this simple requirement?

Thanks

Exception details:

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
  Source=PresentationFramework
  StackTrace:
       at System.Windows.Controls.ItemCollection.CheckIsUsingInnerView()
       at System.Windows.Controls.ItemCollection.Remove(Object removeItem)
       at Telerik.Windows.DragDrop.Behaviors.DragDropBehavior`1.RemoveItems(IList source, IEnumerable items) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropBehavior.cs:line 186
       at Telerik.Windows.DragDrop.Behaviors.DragDropBehavior`1.DragDropCompleted(TState state) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropBehavior.cs:line 161
       at Telerik.Windows.DragDrop.Behaviors.DragDropHelper`2.DragDropCompleted(FrameworkElement dropItemsControl, Object data, Type itemType, Boolean wasCanceled) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropHelper.cs:line 228
       at Telerik.Windows.DragDrop.Behaviors.DragDropHelper`2.CompleteDrag(Object data, DragDropEffects effects) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropHelper.cs:line 398
       at Telerik.Windows.DragDrop.Behaviors.DragDropHelper`2.DragDropCompleted(Object sender, DragDropCompletedEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropHelper.cs:line 392
       at Telerik.Windows.DragDrop.DragDropCompletedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragDropCompletedEventArgs.cs:line 61
       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.RaiseEvent(RoutedEventArgs e)
       at Telerik.Windows.DragDrop.IInputElementExtensions.RaiseEvent(DependencyObject d, RoutedEventArgs routedEventArgs) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DependencyObjectExtensions.cs:line 82
       at Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects, DragDropKeyStates initialKeyState, Object dragVisual, Point relativeStartPoint, Point dragVisualOffset) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragDropManager.cs:line 1026
       at Telerik.Windows.DragDrop.DragInitializer.StartDrag() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragInitializer.cs:line 236
       at Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(UIElement sender) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragInitializer.cs:line 186
       at Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(Object sender, MouseEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragInitializer.cs:line 163
       at System.Windows.Input.MouseEventArgs.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)
  InnerException: 

Dimitrina
Telerik team
 answered on 20 Aug 2012
3 answers
278 views
Hi again,

I have now managed to get the TrackBallInfo popup window to look almost as I want it but one thing remains: I would like to have the header present the datapoint's current Category. 

Having examined all the demos I've seen that I can in fact have the first series also present such a header for me but that won't work if the user opts that data series out of the presentation. I could have a "special" series with null values just to achieve this but that would be very a very clunky solution.

I have also seen that I can use one of the indicators but they all seem to end up at the bottom of the info window.

Could you please direct me to whatever documentation that explains how to template the info window while using the current datapoints?

Thanks
Yavor
Telerik team
 answered on 20 Aug 2012
0 answers
38 views
In   the  behind  code  can't   obtain   the  "Content"     of   Shap   which  is  a  item  of    Diagram control .

This    is   a   serious   problem  ,   indicating   that   the   "  not   will  object    reference    set    to     an    instance   of     an object.   "    error.

XAML:
       <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=RoundedRectangleShape}" 
             x:Name="rd_SiPing" Width="100" Height="35"
             Content="Harvard University"
             Tag="A"
             FontSize="14"
             Position="193,120"
             Background="LightGray"                      
             MouseLeftButtonDown="rd_SiPing_MouseLeftButtonDown" >
                            
            </telerik:RadDiagramShape>


             <telerik:RadDiagramShape Geometry="{telerik:CommonShape ShapeType=RoundedRectangleShape}" 
             x:Name="rd_SiPingValue" Width="100" Height="25"
             Content="1716.0kW"
             Tag="A"
             FontSize="12"
             Position="193,160"
             Background="LightGray"    
            />


Code  behind:
        private void rd_SiPing_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            string str = rd_SiPingValue.Content.ToString();
            string strtwo = rd_Region.Content.ToString();
            string strthree = rd_SiPing.Tag.ToString();

          Question:   Three   lines   of   code   as   above    are   all   prompt     error:   "not   will  object    reference    set    to     an    instance   of     an object."
            Why???    

        } 
Yostec
Top achievements
Rank 1
 asked on 20 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?