Telerik Forums
UI for Universal Windows Platform Forum
1 answer
565 views

Hi There, I'm using the Telerik Datagrid for UWP and it is a pleasure to work with it. I am now developing a datagrid view with several comboboxes to select data from other Lists (Tables in sqlite) and I am struggling with the selected values. I have defined a combobox with the proper data to display but when I select a different record and try to update the change in the record the value is the same as when first initiated. How can i transfer the value? When I use a ordinary combobox the SelectedValuePath and the SelectedValue do the job but this is the datagrid and seems to be different. I searched the net and all questions and also your documentation but didn't find the answer. 

Here's some relevant code: 

XAML:

<Page
    x:Class="GolfComp.Views.TeamListPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:GolfComp.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" 
    xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <RelativePanel>
            <CommandBar x:Name="mainCommandBar" HorizontalAlignment="Stretch" IsEnabled="{x:Bind enableCommandBar}">
                <AppBarButton
                    Click="Insert_new_entry"
                    Icon="Add"
                    Label="New"
                    ToolTipService.ToolTip="New record"/>
                <AppBarButton
                    Click="Delete_Click"
                    Icon="Delete"
                    Label="Delete"
                    ToolTipService.ToolTip="Delete record" />
                <AppBarButton
                    Click="UpdateRecord_Click"
                    Icon="Refresh"
                    Label="Update"
                    ToolTipService.ToolTip="Update record" />
            </CommandBar>
            <StackPanel
                x:Name="newRecordStackPanel"
                Orientation="Horizontal"                
                RelativePanel.Below="mainCommandBar">
                <ComboBox x:Name="golfclubDropDown" Header="Homeclub" Margin="8,8,16,8" MinWidth="150"/>
                <ComboBox x:Name="klasseDropDown" Header="Competitie" Margin="8,8,16,8" MinWidth="150"/>
                <TextBox
                    x:Name="TeamNaamTextBox"
                    Header="Teamnaam"
                    PlaceholderText="teamnaam"
                    Margin="8,8,16,8"/>
                <AppBarButton x:Name="DeleteNewRecord" Click="DeleteNewRecord_Click" Icon="Cancel"/>
                <AppBarButton x:Name="SaveNewRecord" Click="SaveNewRecord_Click" Icon="Save"/>
            </StackPanel>
            <telerikGrid:RadDataGrid 
                AutoGenerateColumns="False"
                x:Name="Datagrid" 
                BorderThickness="0" 
                ColumnDataOperationsMode="Flyout" 
                GridLinesVisibility="None"
                GroupPanelPosition="Left" 
                RelativePanel.AlignLeftWithPanel="True"
                RelativePanel.AlignRightWithPanel="True"
                RelativePanel.Below="newRecordStackPanel"
                UserEditMode="Inline"
                SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}">
                <telerikGrid:RadDataGrid.Columns>
                    <telerikGrid:DataGridComboBoxColumn PropertyName="Competitie" 
                                                        Header="Competitie"                                                         
                                                        ItemsSource="{x:Bind klasse}"
                                                        DisplayMemberPath="Competitie"
                                                        SelectedValuePath="Klasse_Id" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler1Id" Header="Speler 1"/>
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler2Id" Header="Speler 2"/>
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler3Id" Header="Speler 3" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler4Id" Header="Speler 4" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler5Id" Header="Speler 5" />
                    <telerikGrid:DataGridNumericalColumn PropertyName="Speler6Id" Header="Speler 6" />
                    <telerikGrid:DataGridTextColumn PropertyName="Naam" Header="Teamnaam" />
                </telerikGrid:RadDataGrid.Columns>
            </telerikGrid:RadDataGrid>
        </RelativePanel>
    </Grid>

</Page>

C#


namespace GolfComp.Views
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class TeamListPage : Page, INotifyPropertyChanged
    {
        ObservableCollection<SpelerModel> speler = new ObservableCollection<SpelerModel>();
        ObservableCollection<GolfclubModel> golfclub = new ObservableCollection<GolfclubModel>();
        ObservableCollection<TeamModel> team = new ObservableCollection<TeamModel>();
        ObservableCollection<CoachModel> coach = new ObservableCollection<CoachModel>();
        ObservableCollection<KlasseModel> klasse = new ObservableCollection<KlasseModel>();
        bool enableCommandBar = true;
        public TeamListPage()
        {
            this.InitializeComponent();
            newRecordStackPanel.Visibility = Visibility.Collapsed;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            GetData();
            wireUpDropdowns();
            if (Datagrid.ItemsSource == null)
            {
                Datagrid.ItemsSource = team;
            }
        }
        public void GetData()
        {
            string sql1 = "SELECT * from Speler";
            var spelerlijst = SqliteDataAccess.LoadData<SpelerModel>(sql1, new Dictionary<string, object>());
            spelerlijst.ForEach(x => speler.Add(x));

            string sql2 = "select * from Golfclub";
            var golfclublijst = SqliteDataAccess.LoadData<GolfclubModel>(sql2, new Dictionary<string, object>());
            golfclublijst.ForEach(x => golfclub.Add(x));

            string sql3 = "SELECT Team.Id, KlasseId, Speler1Id, Speler2Id, Speler3Id, Speler4Id, Speler5Id, Speler6Id, Team.Naam, Klasse_Id, Klasse_Naam, Klasse_Omschrijving from Team " +
                "INNER JOIN Klasse ON Klasse.Klasse_Id = Team.KlasseId;";
            var teamlijst = SqliteDataAccess.LoadData<TeamModel>(sql3, new Dictionary<string, object>());
            teamlijst.ForEach(x => team.Add(x));

            string sql4 = "select * from Coach";
            var coachlijst = SqliteDataAccess.LoadData<CoachModel>(sql4, new Dictionary<string, object>());
            coachlijst.ForEach(x => coach.Add(x));

            string sql5 = "select * from Klasse";
            var klasselijst = SqliteDataAccess.LoadData<KlasseModel>(sql5, new Dictionary<string, object>());
            klasselijst.ForEach(x => klasse.Add(x));

        }

        private void wireUpDropdowns()
        {
            golfclubDropDown.ItemsSource = golfclub;
            golfclubDropDown.DisplayMemberPath = "Naam";
            golfclubDropDown.SelectedValuePath = "Id";

            klasseDropDown.ItemsSource = klasse;
            klasseDropDown.DisplayMemberPath = "Competitie";
            klasseDropDown.SelectedValuePath = "Klasse_Id";
        }   
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            string sql = "delete from Teams where Id = @Id";
            try
            {
                Dictionary<string, object> parameters = new Dictionary<string, object>
                {
                    { "@Id", SelectedItem.Id }
                };
                SqliteDataAccess.DeleteData(sql, parameters);
                speler.Clear();
                GetData();
            }
            catch
            {
                MessageDialog messagedialog = new MessageDialog("Fout: Selecteer een record");
                _ = messagedialog.ShowAsync();

                return;
            }
        }
        private void UpdateRecord_Click(object sender, RoutedEventArgs e)
        {
            string sql = "update Team set KlasseId = @KlasseId, Speler1Id = @Speler1Id, Speler2Id = @Speler2Id, " +
                "Speler3Id = @Speler3Id, Speler4Id = @Speler4Id, Speler5Id = @Speler5Id, Speler6Id = @Speler6Id, " +
                "Naam = @Naam, CoachId = @CoachId, ClubId = @ClubId, PuntenVoor = @PuntenVoor, PuntenTegen = @PuntenTegen " +
                "where Id = @Id";
            try
            {
                Dictionary<string, object> parameters = new Dictionary<string, object>
                {
                    { "@Id",SelectedItem.Id },
                    { "@KlasseId", SelectedItem.Klasse_Id },
                    { "@Speler1Id", SelectedItem.Speler1Id},
                    { "@Speler2Id", SelectedItem.Speler2Id},
                    { "@Speler3Id", SelectedItem.Speler3Id},
                    { "@Speler4Id", SelectedItem.Speler4Id},
                    { "@Speler5Id", SelectedItem.Speler5Id},
                    { "@Speler6Id", SelectedItem.Speler6Id},
                    { "@Naam", SelectedItem.Naam},
                    { "@CoachId", SelectedItem.CoachId},
                    { "@ClubId", SelectedItem.ClubId},
                    { "@PuntenVoor", SelectedItem.PuntenVoor},
                    { "@PuntenTegen", SelectedItem.PuntenTegen}
                };
                SqliteDataAccess.SaveData(sql, parameters);
                speler.Clear();
                GetData();

                MessageDialog messagedialog = new MessageDialog("Succes: wijzigingen weggeschreven");
                _ = messagedialog.ShowAsync();
            }
            catch (Exception ex)
            {
                MessageDialog messagedialog = new MessageDialog(ex.Message);
                _ = messagedialog.ShowAsync();

                return;
            }
        }
        private void Insert_new_entry(object sender, RoutedEventArgs e)
        {
            enableCommandBar = false;
            newRecordStackPanel.Visibility = Visibility.Visible;
        }
        private void DeleteNewRecord_Click(object sender, RoutedEventArgs e)
        {           
            enableCommandBar = true;
            newRecordStackPanel.Visibility = Visibility.Collapsed;
        }
        private (bool isValid, TeamModel model) ValidateForm()
        {
            bool isValid = true;
            TeamModel model = new TeamModel();

            try
            {
                model.KlasseId = (int)klasseDropDown.SelectedValue;
                model.Speler1Id = 0;
                model.Speler2Id = 0;
                model.Speler3Id = 0;
                model.Speler4Id = 0;
                model.Speler5Id = 0;
                model.Speler6Id = 0;
                model.Naam = TeamNaamTextBox.Text;
                model.CoachId = 0;
                model.ClubId = (int)golfclubDropDown.SelectedValue;
                model.PuntenVoor = 0;
                model.PuntenTegen = 0;

            }
            catch
            {
                isValid = false;
            }
            return (isValid, model);
        }
        private void SaveNewRecord_Click(object sender, RoutedEventArgs e)
        {
            TeamModel model = new TeamModel();

            string sql = "insert into Team (KlasseId, Speler1Id, Speler2Id, Speler3Id, Speler4Id, Speler5Id, Speler6Id, Naam, CoachId, ClubId, PuntenVoor, PuntenTegen ) " +
                "values (@KlasseId, @Speler1Id, @Speler2Id, @Speler3Id, @Speler4Id, @Speler5Id, @Speler6Id, @Naam, @CoachId, @ClubId, @PuntenVoor, @PuntenTegen)";

            var form = ValidateForm();
            if (form.isValid == false)
            {
                MessageDialog messagedialog = new MessageDialog("foutieve invoer. Probeer het opnieuw");

                _ = messagedialog.ShowAsync();

                return;
            }
            if (TeamNaamTextBox.Text == "")
            {
                MessageDialog messagedialog = new MessageDialog("Vul alle velden in");

                _ = messagedialog.ShowAsync();

                return;
            }
            Dictionary<string, object> parameters = new Dictionary<string, object>
            {
                {"@KlasseId", form.model.KlasseId },
                {"@Speler1Id", form.model.Speler1Id },
                {"@Speler2Id", form.model.Speler2Id },
                {"@Speler3Id", form.model.Speler3Id },
                {"@Speler4Id", form.model.Speler4Id },
                {"@Speler5Id", form.model.Speler5Id },
                {"@Speler6Id", form.model.Speler6Id },
                {"@Naam", form.model.Naam },
                {"@CoachId", form.model.CoachId },
                {"@ClubId", form.model.ClubId },
                {"@PuntenVoor", form.model.PuntenVoor },
                {"@PuntenTegen", form.model.PuntenTegen }

            };
            SqliteDataAccess.SaveData(sql, parameters);
            //speler.Add(form.model);
            

            enableCommandBar = true;
            newRecordStackPanel.Visibility = Visibility.Collapsed;

            team.Clear();

            GetData();          

            wireUpDropdowns();
        }
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged([CallerMemberName] string propertyName = null) =>
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

        private TeamModel _selectedItem;

        public TeamModel SelectedItem
        {
            get => _selectedItem;
            set
            {
                if (_selectedItem != value)
                {
                    _selectedItem = value;
                    OnPropertyChanged();
                }
            }
        }
    }
}

Polya
Telerik team
 answered on 15 Sep 2022
1 answer
88 views
Hi,

In a RadCartesianChart with BarSeries, when a value is zero, we do see a 1px color line.

I do believe we should not see anything when a value is zero.

If the rendering engine is the same in WinUI, the behavior is surely there too.

Thanks
Sébastien
Didi
Telerik team
 answered on 12 Sep 2022
1 answer
156 views

I use a telerik datagrid to display my data in UWP. I want to hide the Id column because this is automatically increased field in my SQLite database. I use it however in various methods. the command this.["Name of the grid"].Columns[1].Visability = false produces an exeption,

I tried various other solutions but nothing seems to work.

Regards Rob

I use: Visual studio 2019

Telerik.UI.for.UWP 1.0.2.9

code XAML:

<Page
    x:Class="GolfComp.Views.KlasseListPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" 
    xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"
    mc:Ignorable="d" 
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>

        <RelativePanel>
            <CommandBar x:Name="mainCommandBar" HorizontalAlignment="Stretch" IsEnabled="{x:Bind enableCommandBar}">

                <AppBarButton
                    Click="Insert_new_entry"
                    Icon="Add"
                    Label="New"
                    ToolTipService.ToolTip="New record"/>
                <AppBarButton
                    Click="Delete_Click"
                    Icon="Delete"
                    Label="Delete"
                    ToolTipService.ToolTip="Delete record" />
                <AppBarButton
                    Click="Refresh_Click"
                    Icon="Refresh"
                    Label="Update"
                    ToolTipService.ToolTip="Update record" />
            </CommandBar>
            <StackPanel
                x:Name="newRecordStackPanel"
                Orientation="Horizontal"                
                RelativePanel.Below="mainCommandBar">
                <TextBox
                    Header="Naam Competitie"
                    PlaceholderText="naam"
                    Margin="8,8,16,8"
                    MinWidth="200"
                    x:Name="NaamTextBox" />
                <TextBox
                    Header="Klasse"
                    PlaceholderText="klasse"
                    Margin="8,8,16,8"
                    MinWidth="200"
                    x:Name="klasseTextBox" />
                <AppBarButton x:Name="DeleteNewRecord" Click="DeleteNewRecord_Click" Icon="Cancel"/>
                <AppBarButton x:Name="SaveNewRecord" Click="SaveNewRecord_Click" Icon="Save"/>
            </StackPanel>        
            
            <telerikGrid:RadDataGrid
             x:Name="DataGrid"
             BorderThickness="0"
             ColumnDataOperationsMode="Flyout"
             GridLinesVisibility="None"
             GroupPanelPosition="Left"
             RelativePanel.AlignLeftWithPanel="True"
             RelativePanel.AlignRightWithPanel="True"
             RelativePanel.Below="newRecordStackPanel"                 
             ItemsSource="{x:Bind klasse}"
             UserEditMode="Inline"              
             SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}"/>
            
            
        </RelativePanel>
    </Grid>
    

</Page>   

 

Lance | Manager Technical Support
Telerik team
 answered on 31 Aug 2022
1 answer
101 views
Hi,

My item source contains values from June 23rd and June 24th only.

When I start the app, I set the axis minimum date to today June 27th (and max June 28th).

When I click go previous day to June 24th and June 23rd, data appears -> Good.

However, when I go further in the past or go back to June 25th, 26th, 27th, etc, the data of June 24th are still there!
Yana
Telerik team
 answered on 02 Jul 2022
3 answers
131 views
Hi,

My very short list of data is ordered by time. You will see that the rendering does not make sense.

You can run the sample: ChartBug.

As I understand, we can set the ItemSources of a SeriesSpline for like 1 month of data and control what is shown with the DateTimeContinuousAxis.Minimum and DateTimeContinuousAxis.Maximum values to set the visible range.

Thank you in advance
Sébastien
Yana
Telerik team
 answered on 30 Jun 2022
0 answers
91 views

Hello everybody. I'm not much of a computer expert so I ask you for immense help. I explain you: I am on a website where I have to answer questions by checking the True or False box. on fiddler I set the breakpoints before the response. then I analyze the response. if the response is correct (based on my choice), I deactivate the beakpointn and go ahead with the correct answer. if the response is wrong I would like to modify the response so that it is correct, or divert / redirect / destroy the wrong response so that the error is not reported to me and consequently I can modify my choice. I hope I explained myself

Pippo
Top achievements
Rank 1
 asked on 29 Jun 2022
1 answer
74 views

Hi,

I noticed this bad effect today. My main view has 3 RadCartesianChart:
- SplineSeries (Minute)
- BarSeries (Hour)
- BarSeries (Day)

If I opened the app then navigate to previous dates in the default chart, you can see that the performance is amazing. There is actually 1440 data points. Then if I go to the day view that has like 30 data points and go back to the first chart, the performance is super bad.

In the second part of the video, I do the same exercise except I do not even navigate to previous dates, it means that the default chart has NO data in it! However, going to day chart then minute chart, the performance goes bad.

Sorry for the "spam" of bugs lately.

Thanks
Sébastien

Sébastien
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 29 Jun 2022
0 answers
68 views
Hi,

Today, Lance (Telerik) updated my sample provided in https://www.telerik.com/forums/radcartesianchart-datetimecontinuousaxis-minimum-and-maximum-are-not-respected to bypass the bug on the Min/Max not taking into account.

I re-updated the sample (attached) with 2 videos. The sample is in line with my business app: 1440 data point per serie (up to 5 series).

The performance of LineSeries are really bad, I'm quite surprised because these are just lines.

However, if you replace the "<chart:LineSeries" in MainPage.xaml to "<chart:SplineSeries", it is like in real-time when changing the date. This is awesome and frankly I do not understand how come it is fast versus LineSeries where it takes 3 to 5 seconds to refresh. You can see the 2 videos.

My only fear is Spline has the following bug https://www.telerik.com/forums/radcartesianchart-weird-rendering

Thanks
Sébastien
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 28 Jun 2022
1 answer
223 views
Hi,

1- Run the app
2- After short time, you will see that the chart refreshes.

Data is added in real time on a 1 second timer, you can put the timer at 2 seconds and you will see the issu.e

With very few data, I would expect the Chart to not cause a flickering.

Thank you
Didi
Telerik team
 answered on 30 May 2022
2 answers
163 views
Hi,

My goal is to create dynamically columns. Columns are added via a timer event. I have access to the data before to set the DataContext.

I found that the DataGrid has the method HitTestService.CellInfoFromPoint/RowItemFromPoint, but it requires a point.

Alternatively, is there a way that I could set the DataContext in another way?
Yana
Telerik team
 answered on 06 May 2022
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?