0

I have a ResourceDictionary that I added a codebehind to.

In the ResourceDictionary I have a combobox. I want to bind the ItemsSource of that combobox to a List in the codebehind.

How can I set the source of my binding so that it looks in the codebehind?

This one uses the code behind --------+
                                      |
                                      V
<ComboBox  PreviewKeyDown="CustomItem_PreviewKeyDown"
           ItemsSource="{Binding AllItems, Source={CodeBehind} />
                     ^                                   ^
                     |                                   |
But this one doesn't | because the source is not correct |

In case it matters, this is what the start of my ResourceDictionary looks like:

<ResourceDictionary 
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                x:Class="MyProject.MyCodeBehindClass"
                x:Name="ANameThatSeemsUselessHere">

Any ideas on how I could get the ItemSource binding to the ResourceDictionary codebehind?

Community
  • 1
  • 1
Vaccano
  • 78,325
  • 149
  • 468
  • 850

1 Answers1

0

I think its something like DataContext ="{Static Resource ANameTheSeemsUsl

KitWat
  • 35
  • 2
  • 4