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 8908477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:11:23+00:00 2026-06-15T03:11:23+00:00

i have this DataTemplate: <ResourceDictionary xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:Model=clr-namespace:Effectus.Model xmlns:Controls=clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit > <DataTemplate DataType={x:Type Model:ToDoAction}> <Grid>

  • 0

i have this DataTemplate:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Model="clr-namespace:Effectus.Model"
xmlns:Controls="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
>

<DataTemplate DataType="{x:Type Model:ToDoAction}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <TextBlock Text="Title" 
                   Grid.Row="0" Grid.Column="0"/>
        <TextBox Text="{Binding Path=Title}"
                   IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},Path=DataContext.AllowEditing.Value}"
                   Grid.Row="0" Grid.Column="1"/>

        <TextBlock Text="Content" 
                   Grid.Row="1" Grid.Column="0"/>
        <TextBox Text="{Binding Path=Content}"
            IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},Path=DataContext.AllowEditing.Value}"
            AcceptsReturn="True"
            MinHeight="100"
            Grid.Row="2" Grid.ColumnSpan="2"/>

        <TextBlock Text="Owner"
                   Grid.Row="6" Grid.Column="0"/>
        <ComboBox SelectedItem="{Binding Path=Owner}" DisplayMemberPath="Username" SelectedValuePath="Username"
                  ItemsSource="{Binding Converter={StaticResource EnumValuesConverter}, ConverterParameter={x:Type Model:Status}}"
                  IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},Path=DataContext.AllowEditing.Value}"
                  Grid.Row="6" Grid.Column="1"/>

    </Grid>
</DataTemplate>

In the last part you can see a TextBlock whose Text is “Owner”, followed by a ComboBox.
Just to give you the context, this is a little part of a ToDo app that i’m currently working on (i’m trying to get into MVVM).
The XAML i poted is the DataTemplate of the ToDoAction objects.
I want the “Owner” ComboBox to be filled by all users. I can get them from DB through NHibernate but i don’t have the faintest idea on how to bind the DataTemplate to my DataSource (a Nhibernate Session in my case, but i feel this is more general).
Can you give some little advise please?
Thank you all very much!

  • 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-15T03:11:24+00:00Added an answer on June 15, 2026 at 3:11 am

    There are multiple ways to handle that like the ObjectDataProvider which i never used. But i think the most easiest and fastest is to use a singleton.

    public sealed class UserList
    {
        public ObservableCollection<User> Users {get; private set;}
    
        public static UserList Instance
        {
            get{return sInstance;}
        }
    
        private static UserList sInstance = new UserList();
    }
    

    you can update and modify the Users list as usual and the bindings to this collection must be.

    ItemsSource="{Binding Source={x:Static my:UserList.Instance}, Path=Users}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this in xaml file: <Window x:Class=TestTool.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:RecoConfigTool=clr-namespace:TestTool Title=Window1 Height=300 Width=300>
I have this XAML: <UserControl x:Class=M_Cubed.Controls.TagEditor xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:classes=clr-namespace:M_Cubed.Classes> <UserControl.Resources> <DataTemplate DataType={x:Type classes:TagEditorPic}> <ComboBox
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
I have a xaml file with this code: <GridViewColumn x:Name=lvCol3 Header=Quantità Width=120> <GridViewColumn.CellTemplate> <DataTemplate>
I have a DataTemplate inside a global/shared ResourceDictionary like this which targets a DataType:
I have a ResourceDictionary such as (MyResourceDictionary): <ResourceDictionary xmlns ..... > <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source=SeriesTwo.xaml
I have a ResourceDictionary , which contains a DataTemplate . Within this DataTemplate's Resources
I have this code for xaml section <ListBox Margin=0,0,-12,0 Visibility=Visible ItemsSource={Binding QuestionsCurrent.Answers}> <ListBox.ItemTemplate> <DataTemplate>
I have this method call: public DataTemplate Create(Type type, string propertyName) { string str
I have this grid, containing a template: <Grid x:Name=Bar Width=400> <Grid.Resources> <DataTemplate x:Name=ScoreText> <Grid

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.