Click here to Skip to main content
15,918,193 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Resource Dictionary in subprojects Pin
Eslam Afifi29-Jun-09 15:31
Eslam Afifi29-Jun-09 15:31 
GeneralRe: Resource Dictionary in subprojects Pin
User 27100929-Jun-09 15:37
User 27100929-Jun-09 15:37 
GeneralRe: Resource Dictionary in subprojects Pin
Eslam Afifi29-Jun-09 15:39
Eslam Afifi29-Jun-09 15:39 
QuestionHow to get the control position to add another control below that? Pin
salon24-Apr-09 2:30
salon24-Apr-09 2:30 
AnswerRe: How to get the control position to add another control below that? Pin
Ray Cassick24-Apr-09 3:16
Ray Cassick24-Apr-09 3:16 
AnswerRe: How to get the control position to add another control below that? Pin
Mark Salsbery25-Apr-09 7:42
Mark Salsbery25-Apr-09 7:42 
Questionrendertransformorigin fails Pin
VCsamir24-Apr-09 1:56
VCsamir24-Apr-09 1:56 
QuestionWeird behavior styling a Border Pin
Foxandxss23-Apr-09 13:34
Foxandxss23-Apr-09 13:34 
AnswerRe: Weird behavior styling a Border Pin
#realJSOP23-Apr-09 22:38
professional#realJSOP23-Apr-09 22:38 
GeneralRe: Weird behavior styling a Border Pin
Pete O'Hanlon23-Apr-09 23:16
mvePete O'Hanlon23-Apr-09 23:16 
GeneralRe: Weird behavior styling a Border Pin
#realJSOP24-Apr-09 2:07
professional#realJSOP24-Apr-09 2:07 
GeneralRe: Weird behavior styling a Border Pin
Foxandxss23-Apr-09 23:40
Foxandxss23-Apr-09 23:40 
QuestionMessage Removed Pin
23-Apr-09 10:46
professionalN_tro_P23-Apr-09 10:46 
AnswerRe: WPF DateTime picker Pin
#realJSOP23-Apr-09 10:48
professional#realJSOP23-Apr-09 10:48 
AnswerRe: WPF DateTime picker Pin
Mark Salsbery23-Apr-09 11:16
Mark Salsbery23-Apr-09 11:16 
GeneralMessage Removed Pin
23-Apr-09 11:40
professionalN_tro_P23-Apr-09 11:40 
GeneralRe: WPF DateTime picker Pin
Mark Salsbery23-Apr-09 12:40
Mark Salsbery23-Apr-09 12:40 
GeneralMessage Removed Pin
24-Apr-09 2:55
professionalN_tro_P24-Apr-09 2:55 
GeneralRe: WPF DateTime picker Pin
Mark Salsbery24-Apr-09 6:01
Mark Salsbery24-Apr-09 6:01 
Questione.currentTarget in WPF? Pin
emptythetill23-Apr-09 8:52
emptythetill23-Apr-09 8:52 
AnswerRe: e.currentTarget in WPF? Pin
Pete O'Hanlon24-Apr-09 2:11
mvePete O'Hanlon24-Apr-09 2:11 
GeneralRe: e.currentTarget in WPF? Pin
emptythetill24-Apr-09 3:48
emptythetill24-Apr-09 3:48 
GeneralRe: e.currentTarget in WPF? Pin
Pete O'Hanlon24-Apr-09 4:30
mvePete O'Hanlon24-Apr-09 4:30 
QuestionData Binding Problem [modified] Pin
#realJSOP23-Apr-09 7:52
professional#realJSOP23-Apr-09 7:52 
I have the following collection:

public class WorkTrayItem
{
    public TabItem WindowAccountTab { get; set; }
    public string WindowSource { get; set; }
    public Window WindowObject { get; set; }
    public Image WindowIcon { get; set; }
    public int WindowType { get; set; }
    public string WindowName { get; set; }

    public WorkTrayItem(TabItem tab, Window window, string source, int windowType, Image icon)
    {
        WindowObject = window;
        WindowSource = source;
        WindowAccountTab = tab;
        WindowType = windowType;
        WindowIcon = icon;
        switch (windowType)
        {
            case 0 : WindowName = "Service Order"; break;
            case 1 : WindowName = "Trouble Ticket"; break;
        }
    }
}

public class WorkTrayItems : ObservableCollection<worktrayitem>
{
    public WorkTrayItems()
    {
        this.Clear();
    }
}


I'm trying to bind it to a list view:

    <UserControl.Resources>

        <controls:WorkTrayItems x:Key="WorkTrayData" />

        <Style TargetType="{x:Type ListView}" BasedOn="{StaticResource {x:Type ListBox}}">
            <Setter Property="ItemsSource" Value="{Binding Source={StaticResource WorkTrayData}}">
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border Name="bd" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" 
                                Margin="{TemplateBinding Margin}">
                            <ScrollViewer Margin="{TemplateBinding Padding}">
                                <WrapPanel ItemWidth="150" IsItemsHost="True" Name="wrapPanel1" MinWidth="100" 
                                           Width="{Binding ActualWidth, 
                                                           RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                          AncestorType=ScrollContentPresenter}}">
                                </WrapPanel>
                            </ScrollViewer>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType='{x:Type ListViewItem}' BasedOn='{StaticResource {x:Type ListBoxItem}}'>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <StackPanel.DataContext>
                                <Binding Source="{StaticResource WorkTrayData}" />
                            </StackPanel.DataContext>
                            <Image Margin="3" Source="{Binding WindowImage}"/>
                            <Label Height="21" HorizontalContentAlignment="Center" 
                                      VerticalContentAlignment="Top" 
                                      Content="{Binding WindowTitle}"/>
                            <Label Height="21" HorizontalContentAlignment="Center" 
                                      VerticalContentAlignment="Top" 
                                      Content="{Binding WindowSource}"/>
                        </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type controls:ImageView},ResourceId=ImageView}">
        </Style>

        <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type controls:ImageView},ResourceId=ImageViewItem}">
        </Style>
    </UserControl.Resources>

<Grid>
                        <ListView Name="listViewWorkTray"  
                                   Margin="8,0,7,-116" BorderThickness="0" Background="Transparent" 
                                   SelectionMode="Single" FontFamily="Arial" Height="109" 
                                   VerticalAlignment="Bottom">
                            <ListView.View>
                                <controls:ImageView />
                            </ListView.View>
                        </ListView>
</Grid>


When a user opens a window, I add a WorkTrayItem object to the collection, but it doesn't show up in the ListView. What am I missing? Somehow, I feel like I need to tell the XAML what the variable name is of the list in the parent control (m_workTrayData), but how/where should I do that?


"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 Friday, April 24, 2009 8:05 AM

AnswerRe: Data Binding Problem Pin
#realJSOP23-Apr-09 8:35
professional#realJSOP23-Apr-09 8:35 

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.