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

  • SEARCH
  • Home
  • 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 8101063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:53:40+00:00 2026-06-05T22:53:40+00:00

I’m developing an application using the WAF (WPF Application Framework) which is based on

  • 0

I’m developing an application using the WAF (WPF Application Framework) which is based on MVVM, MEF, etc.

I currently have a couple of Domain objects with similar structures as below (shortened for brevity):

public class MyBaseClass : INotifyPropertyChanged
{
    private DateTime? _firstDateTime;
    protected DateTime? firstDateTime
    {
        get { return _firstDateTime; }
        set
        {
            _firstDateTime = value;
            OnPropertyChanged(new PropertyChangedEventArgs("FirstDateTime"));
    }

    private DateTime? _secondDateTime;
    protected DateTime? secondDateTime
    {
        get { return _secondDateTime; }
        set
        {
            _secondDateTime = value;
            OnPropertyChanged(new PropertyChangedEventArgs("SecondDateTime"));
    }

    public DateTime? FirstDateTime
    {
        get { return firstDateTime; }
        set { firstDateTime = value; }
    }

    public DateTime? SecondDateTime
    {
        get { return secondDateTime; }
        set { secondDateTime = value; }
    }
}

public class MyBaseCollectionClass : INotifyPropertyChanged
{
    private ObservableCollection<MyBaseClass> _baseClassObjectCollection;
    protected ObservableCollection<MyBaseClass> baseClassObjectCollection
    {
        get { return _baseClassObjectCollection; }
        set
        {
            _baseClassObjectCollection = value;

            OnPropertyChanged(new PropertyChangedEventArgs("BaseClassObjectCollection"));
        }
    }        

    public ObservableCollection<MyBaseClass> BaseClassObjectCollection
    {
        get { return baseClassObjectCollection; }
        set { baseClassObjectCollection = value; }
    }
}

Then, in my ApplicationController I have a method that loads up an ObservableCollection in a view-model like such:

for (int i = 0; i <= 9; i++)
{
    detailsViewModel.MyBaseClassObjects.Add( new MyBaseClass()
                                            {
                                                FirstDateTime = Convert.ToDateTime("05/2" + i + "/2012 09:00:00 AM"),
                                                SecondDateTime = Convert.ToDateTime("05/2" + i + "/2012 04:30:00 PM")
                                            });
}

And another method that groups the big collection into smaller grouped collections by date:

detailsViewModel.MyBaseClassObjects
                .GroupBy(baseObject => ((DateTime)baseObject.FirstDateTime).Date)
                .Select(group => group.ToList())
                .ToList()
                .ForEach(list => detailsViewModel.BaseObjectCollections
                        .Add(
                              new MyBaseCollectionClass()
                              { BaseClassObjectCollection = new ObservableCollection<MyBaseClass>(list)}
                             )
                         );

Then, in my view’s XAML, I have an ItemsControl bound like such:

<ItemsControl ItemsSource="{Binding BaseObjectCollections}" ItemTemplate="{StaticResource ItemsTemplate}">                    
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

An in a ResourceDictionary for the view, I have a DataTemplate declared like such (some items omitted for clarity):

<DataTemplate x:Key="ItemsTemplate">
    <Grid DataContext="{Binding MyBaseClassObjects}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>            

        <DataGrid Grid.Row="1"
                      Background="Transparent"
                      Style="{DynamicResource DataGridStyle}"
                      AlternatingRowBackground="Gainsboro"
                      AlternationCount="2"
                      AutoGenerateColumns="False"
                      HeadersVisibility="None"
                      ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}}, Path=DataContext}">
            <DataGrid.Columns>
                <DataGridTextColumn Width=".25*">
                    <DataGridTextColumn.Binding>
                        <MultiBinding Converter="{x:Static myConvNS:MultiValueTESTCONVERTER.Retrieve}">
                            <Binding Path="FirstDateTime"/>
                            <Binding Path="SecondDateTime"/>
                        </MultiBinding>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>                    
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</DataTemplate>

NOTE: In the above DataTemplate I have a multibinding currently so I can see what values are being passed into the converter. I realize I will not be able to achieve the desired effect (described below), but I wanted to be able to step through the binding and look at what the converter was receiving – nothing more at this point.
Ultimately what I’m trying to accomplish (if possible) is that I’d like to be able to bind my Datagrid in such a way that the FirstDateTime and SecondDateTime values can be displayed in the same column, alternating. See the image below for a visual aid:

Desired Effect

My initial thoughts were to have some other generic object that exposes a single DateTime property and break down my base objects (which have two DateTime properties) into instances of this generic object, then bind to a collection of those generic objects. However, I don’t like this idea. When a change occurs to either DateTime properties on my base object I need to know about it and I’m afraid that by splitting this object into two generic objects that I will lose the ability to send/receive the notifications correctly.

Anyone have any suggestions or thoughts?

  • 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-05T22:53:41+00:00Added an answer on June 5, 2026 at 10:53 pm

    what about a DataGridTemplateColumn and just use a StackPanel with your two Textboxes?

    <DataGridTemplateColumn>
        <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBox Text="{Binding FirstDateTime}"/>
                    <TextBox Text="{Binding SecondDateTime}"/>
                </StackPanel>
            </DataTemplate>
        </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
Thanks in advance for your help. I have a need within an application to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.