Click here to Skip to main content
15,886,919 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Listbox items - how to "owner draw" Pin
ABitSmart23-Mar-09 17:28
ABitSmart23-Mar-09 17:28 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP23-Mar-09 23:20
mve#realJSOP23-Mar-09 23:20 
AnswerRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 1:30
mvePete O'Hanlon24-Mar-09 1:30 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP24-Mar-09 2:55
mve#realJSOP24-Mar-09 2:55 
GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 3:24
mvePete O'Hanlon24-Mar-09 3:24 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP24-Mar-09 3:56
mve#realJSOP24-Mar-09 3:56 
GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 5:37
mvePete O'Hanlon24-Mar-09 5:37 
GeneralRe: Listbox items - how to "owner draw" [modified] Pin
#realJSOP24-Mar-09 10:01
mve#realJSOP24-Mar-09 10:01 
Well, it doesn't like part of the xaml stuff (I had implemented all of the stuff you showed before I saw your message). Here's what I have:

namespace AnagramsWPF
{

    public class WordItem
    {
        public string Text  {  get; set; } 
        public bool Used { get; set; }

        public WordItem(string text)
        {
            Text      = text;
            Used      = false;
        }

	public override string ToString()
        {
            return Text;
        }
    }


    public class WordTypeTemplateSelector : DataTemplateSelector
    {
        public DataTemplate UnusedWordTemplate { get; set; }
        public DataTemplate UsedWordTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            WordItem wordItem = item as WordItem;
            DataTemplate template = null;
            if (wordItem.Used)
            {
                template = UsedWordTemplate;
            }
            else
            {
                template = UnusedWordTemplate;
            }
            return template;
        }
    }
}


In the xaml, I have this:

<Window.Resources>
    <DataTemplate x:Key="unusedWord">
        <Grid>
            <TextBlock Text="{Binding Path=Text}" Foreground="DarkGray" />
        </Grid>
    </DataTemplate>
    <DataTemplate x:Key="usedWord">
        <Grid>
            <TextBlock Text="{Binding Path=Texe}" Foreground="Red" FontStyle="Italic" />
        </Grid>
    </DataTemplate>
    <local:WordTypeTemplateSelector
        x:Key="wordTypeTemplateSelector"
        UsedWordTemplate="{StaticResource usedwordTemplate}"
        UnusedWordTemplate="{StaticResource unusedwordTemplate}" />
</Window.Resources>


It doesn't like the underlined portion (it shows the error - "The type 'local:WordTypeTemplateSelector' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.").

I don't need the ObservableCollection stuff because the words are already in the collection before the user starts putting words into the listbox.


"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


modified on Tuesday, March 24, 2009 4:15 PM

GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon24-Mar-09 11:20
mvePete O'Hanlon24-Mar-09 11:20 
GeneralRe: Listbox items - how to "owner draw" Pin
#realJSOP25-Mar-09 3:29
mve#realJSOP25-Mar-09 3:29 
GeneralRe: Listbox items - how to "owner draw" Pin
Pete O'Hanlon25-Mar-09 3:44
mvePete O'Hanlon25-Mar-09 3:44 
GeneralRe: Listbox items - how to "owner draw" Pin
RugbyLeague30-Mar-09 3:51
RugbyLeague30-Mar-09 3:51 
QuestionLoad project into canvas Pin
emptythetill23-Mar-09 10:55
emptythetill23-Mar-09 10:55 
AnswerRe: Load project into canvas Pin
Christian Graus23-Mar-09 15:21
protectorChristian Graus23-Mar-09 15:21 
GeneralRe: Load project into canvas Pin
emptythetill24-Mar-09 7:41
emptythetill24-Mar-09 7:41 
QuestionDrag drop preview Pin
anishkannan23-Mar-09 0:54
anishkannan23-Mar-09 0:54 
AnswerRe: Drag drop preview [modified] Pin
sivaddrahcir23-Mar-09 11:45
sivaddrahcir23-Mar-09 11:45 
QuestionDownloading file from server Pin
sumit703422-Mar-09 23:50
sumit703422-Mar-09 23:50 
AnswerRe: Downloading file from server Pin
Mark Salsbery23-Mar-09 9:51
Mark Salsbery23-Mar-09 9:51 
GeneralRe: Downloading file from server Pin
sumit703423-Mar-09 18:59
sumit703423-Mar-09 18:59 
AnswerRe: Downloading file from server Pin
Braulio Dez1-Apr-09 5:58
Braulio Dez1-Apr-09 5:58 
QuestionRoutedEvent compare to event? Pin
mildred-frontfree22-Mar-09 23:34
mildred-frontfree22-Mar-09 23:34 
AnswerRe: RoutedEvent compare to event? Pin
ABitSmart23-Mar-09 0:04
ABitSmart23-Mar-09 0:04 
GeneralRe: RoutedEvent compare to event? Pin
mildred-frontfree23-Mar-09 0:24
mildred-frontfree23-Mar-09 0:24 
GeneralRe: RoutedEvent compare to event? Pin
Pete O'Hanlon23-Mar-09 1:00
mvePete O'Hanlon23-Mar-09 1:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.