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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:13:33+00:00 2026-05-17T01:13:33+00:00

I’ve started a new job this week and am trying to get my head

  • 0

I’ve started a new job this week and am trying to get my head around this WPF stuff.

I’ve gotten to a point where I’m trying to add a ComboBox to a UserControl, and to populate it from a collection which exists in code.

I’ve been getting along pretty much on monkey-see-monkey-do coding for the most part; copying and adapting existing code in order to get the next stage working, but this DataSource stuff has me stumped. I’ve been through a whole bunch of articles on MSDN this morning and am no closer to understanding than I was when I started.

Let me go through a few of the things that are messing with me, and hopefully you guys will be able to point me in the right direction:

1) None of the [UserControlName].vb files contains any code. All of the code for the UserControls is stored in [UserControlName]Model.vb files, and then code of the following sort is used:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:MySolution"
x:Class="UserControlName"
<UserControl.Resources>
    <l:UserControlNameModel x:Key="UserControlNameModelDataSource" />
</UserControl.Resources>
<UserControl>

I have no idea why this is done. Ideas?

1.5) (using bullet points means I can’t use <> brackets or code blocks later on. What the hell, markdown?) Anyway…

2) I’m pretty sure I only want a Static Source for the moment, as the items in the ComboBox aren’t going to change during execution, at this time. Problem is, all the articles I can find about this are gigantic, complex things about creating XML readers, and populating DataGridViews and sorting data, and on and on and on. I just want to declare that I’m using a frealing List! A List I’ve already created in code.

So, yeah, I basically need to use a Public Property ComboBoxLines As List(Of String) from a class which isn’t the same class as the UserControl itself as the DataSource for a ComboBox.

Any ideas?

  • 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-05-17T01:13:34+00:00Added an answer on May 17, 2026 at 1:13 am

    1) XAML is just object graphs serialized to XML with some whipped cream and cherries on top. So when the xaml is deserialized a new instance of UserControlNameModel is instantiated and added to the Resources collection of the UserControl under the key UserControlblahblah. Its an alternative of doing this in the codebehind and serves no special purpose… other than avoiding codebehind, which I like to do as well.

    As to why the codebehind is empty and everything is defined in a [control nmae]Model.vb file is because whoever wrote this is using the M-V-VM pattern. Its MVC for WPF (MVC tweaked for WPF binding goodness). If you don’t know or understand MVVM, just search for it. Tons of info out there. Also, codebehind is evil. Eeevil.

    2) Easy enough (sorry, C# code ahead):

    // a static class that defines combo box values for user control x lol kthx
    public static class ComboBoxLines
    {  
      public static string[] Values = new string[]{ "One", "Two", "Three" };
    }
    

    in xaml:

    <ComboBox 
      xmlns:src="clr-namespace:Where.ComboBoxLines.IsDefined"
      ItemsSource="{x:Static src:ComboBoxLines.Values}" />
    

    This is the static way to do this. Of course, you could use an instance as well, or define the list in the [lol]Model.vb file and just bind to that…

    • 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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

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.