Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9023109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:40:59+00:00 2026-06-16T05:40:59+00:00

I have alarm model objects which have a Repeat collection containing the days the

  • 0

I have alarm model objects which have a Repeat collection containing the days the alarm should repeat. I want to display the alarms in a grid view grouped under the day of the week(like monday,tuesday etc).

And i am adding all these alarms into a collection “Alarms”

For each alarm in alarms, I am again creating alarms for each day in the repeat collection of the alarm and adding them all to a collection “TotalAlarms”.

foreach (Alarm alarm in this.Config.Alarms)
        {
            foreach (DayOfWeek day in alarm.Repeat)
            {
                this.tempAlarm = this.CopyAlarm(alarm);

                tempAlarm.DayOfWeek = day;                 

                TotalAlarms.Add(tempAlarm);
            }
        }

And am using linq to group on the DayOfWeek property of alarm model which indicates the day on which the alarm should go off.

var result = from t in _ViewModel.TotalAlarms
                     group t by  t.DayOfWeek into q                        
                     orderby q.Key
                     select q;

And am adding this result to the groupedItemsViewSource (binding to itemsource of grid view)

groupedItemsViewSource.Source = result;

and for the header of the grid view, am binding it to “Key”

<TextBlock Text="{Binding Key}" Style="{StaticResource TitleTextStyle}" FontSize="20" HorizontalAlignment="Stretch" VerticalAlignment="Center" Width="100" Height="30" Margin="5"/>

This approach displays only the days of week for which there is an alarm. Like if the alarms are set to friday and saturday, only friday and saturday are shown in the group headers.

What i want is all the days beings shown as group headers and if there are no alarms for that day then it can be empty. But the group headers should display all days.

I am really finding it hard to think of a way to do that. If anyone has any idea, please help me out here….

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:41:00+00:00Added an answer on June 16, 2026 at 5:41 am

    I finally figured out the answer myself. Its a bit messy and ugly but it works. I use 7 grid views now instead of one. But it still doesnt show the header unless there is a data item in the grid view. SO if the grid view collection is empty then i add some empty object to the collection binding the grid view and then i reduce the height of the grid view so that the empty item is not displayed and only the header is displayed.

    This is the sample code for one grid view.

     emptyAlarmsList = new ObservableCollection<Alarm>();
            emptyAlarmsList.Add(new Alarm());
    
            var sundayAlarms = from t in _ViewModel.TotalAlarms
                               where t.DayOfWeek == DayOfWeek.Sunday
                               group t by t.DayOfWeek into g
                               orderby g.Key
                               select g;
    
            if (sundayAlarms.Count() == 0)
            {
                var sundayEmptyAlarms = from t in this.emptyAlarmsList                                   
                                   group t by t.DayOfWeek into g
                                   orderby g.Key
                                   select g;
                SundayAlarmsView.Source = sundayEmptyAlarms;
                itemGridView1.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
                itemGridView1.Height = 100;
            }
            else
                SundayAlarmsView.Source = sundayAlarms;
    

    And the XAMl code for one grid view

     <CollectionViewSource
            x:Name="SundayAlarmsView"            
            IsSourceGrouped="true"
            />
                <GridView
            x:Name="itemGridView1"
            AutomationProperties.AutomationId="ItemGridView1"
            AutomationProperties.Name="Grouped Items"            
            Grid.Column="0"
            Margin="0,-3,0,0"
            Padding="116,0,40,46"
            SelectionMode= "Extended"
            ItemsSource="{Binding Source={StaticResource SundayAlarmsView}}"
            ItemTemplate="{StaticResource AlarmListTemplate}"
            SelectionChanged="Alarm_SelectionChanged">
    
                    <GridView.ItemContainerStyle>
                        <Style
                    TargetType="GridViewItem">
                            <Setter
                        Property="Height"
                        Value="150" />
                            <Setter
                        Property="Width"
                        Value="250" />
                            <Setter
                        Property="Margin"
                        Value="10,10" />
                        </Style>
                    </GridView.ItemContainerStyle>
    
                    <GridView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </GridView.ItemsPanel>
                    <GridView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
    
                                    <TextBlock Text="Sunday" Style="{StaticResource TitleTextStyle}" FontSize="20" HorizontalAlignment="Stretch" VerticalAlignment="Center" Width="100" Height="30" Margin="5"/>
    
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                        </GroupStyle>
                    </GridView.GroupStyle>
                </GridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Homework Planner application which I want to create an Alarm for
I have an AlarmReceiver class which executes when alarm rings at a particular time
I have an android app with the following Alarms setup: Alarm A is of
I have generated XML(alarms.xml) in format (example) <markers> <marker lat=41.932797 lng=21.483765 alarm=Boston severity=0 />
I have an application ( Amnesia ) which lets you create memos/stickers/alarms/Phone Book, and
I have a model with some scopes defined on it: class Alarm < ActiveRecord::Base
I have an application in which i have made a alarm clock. In my
I am having a reminder application in which i have an alarm manager like
Well I have an alarm that should be called every day, but its not
I have application, which makes event in alarm manager, and at specific time its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.