Click here to Skip to main content
15,878,945 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Binding To One Object Or To A Property Pin
Pete O'Hanlon5-Feb-09 10:40
mvePete O'Hanlon5-Feb-09 10:40 
GeneralRe: Binding To One Object Or To A Property Pin
BlitzPackage6-Feb-09 9:42
BlitzPackage6-Feb-09 9:42 
GeneralRe: Binding To One Object Or To A Property Pin
Pete O'Hanlon6-Feb-09 10:53
mvePete O'Hanlon6-Feb-09 10:53 
QuestionMessage Removed Pin
4-Feb-09 10:34
professionalN_tro_P4-Feb-09 10:34 
AnswerMessage Removed Pin
4-Feb-09 10:55
professionalN_tro_P4-Feb-09 10:55 
GeneralRe: DataTemplate list Horizontally Pin
Gideon Engelberth4-Feb-09 12:04
Gideon Engelberth4-Feb-09 12:04 
GeneralMessage Removed Pin
5-Feb-09 4:36
professionalN_tro_P5-Feb-09 4:36 
GeneralRe: DataTemplate list Horizontally Pin
Gideon Engelberth5-Feb-09 6:30
Gideon Engelberth5-Feb-09 6:30 
The grid rows and columns are created in the code-behind. From the referenced post:

'finds the actual grid used by the list box
Dim d As DependencyObject
d = VisualTreeHelper.GetParent( _
        lstItems.ItemContainerGenerator.ContainerFromIndex(0))
While Not (d Is Nothing OrElse d.GetType() Is GetType(Grid))
    d = VisualTreeHelper.GetParent(d)
End While
If d Is Nothing Then Exit Sub

'once you have the grid, you need to add the rows and columns
Dim rd As RowDefinition
Dim cd As ColumnDefinition
Dim grd As Grid = CType(d, Grid)
lstItems.SetValue(Grid.IsSharedSizeScopeProperty, True)
For i As Integer = 0 To 63
    rd = New RowDefinition
    rd.Height = New GridLength(1, GridUnitType.Star)
    grd.RowDefinitions.Add(rd)
    cd = New ColumnDefinition
    cd.Width = New GridLength(1, GridUnitType.Star)
    grd.ColumnDefinitions.Add(cd)
Next
'this is just for debugging purposes
grd.ShowGridLines = True


You have the right ItemsPanel and ItemContainerStyle, now you just need to bind to the ItemsSource property to get the items. Since you seem to have something you can bind to in XAML, just move the ItemsSource binding from the inner ItemsControl to the ListBox and get rid of the ItemsControl.
<!-- moved the data binding for AvailableObjects to here -->
<ListBox Name="lstItems" Background="Green" ItemsSource="{Binding Path=AvailableObjects}>
        <ListBox.ItemsPanel>
            <!-- what you have here is right -->
        </ListBox.ItemsPanel>
        <ListBox.ItemContainerStyle>
            <!-- what you have here is right -->
        </ListBox.ItemContainerStyle>
        
        <!-- this is wrong, you are adding an items control to the list box
             as its only item, you need to do set ItemsSource instead -->
        <ItemsControl FontWeight="Normal" ItemsSource="{Binding Path=AvailableObjects}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Button
                            Grid.Row="{Binding Path=YLoc}"
                            Grid.Column="{Binding Path=XLoc}"
                            Content="{Binding Path=ObjectText}"
                            Margin="2,3.5"
                        />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ListBox>

GeneralMessage Removed Pin
5-Feb-09 8:29
professionalN_tro_P5-Feb-09 8:29 
GeneralMessage Removed Pin
6-Feb-09 3:02
professionalN_tro_P6-Feb-09 3:02 
GeneralMessage Removed Pin
6-Feb-09 6:02
professionalN_tro_P6-Feb-09 6:02 
GeneralRe: DataTemplate list Horizontally Pin
Gideon Engelberth6-Feb-09 7:13
Gideon Engelberth6-Feb-09 7:13 
QuestionMessage Removed Pin
4-Feb-09 5:55
professionalN_tro_P4-Feb-09 5:55 
AnswerMessage Removed Pin
4-Feb-09 7:57
professionalN_tro_P4-Feb-09 7:57 
GeneralRe: ListBox SelectedItems binding Pin
Gideon Engelberth5-Feb-09 3:02
Gideon Engelberth5-Feb-09 3:02 
QuestionAccessing silverlight application throw outlook addin Pin
AR Reddy3-Feb-09 22:31
AR Reddy3-Feb-09 22:31 
QuestionRe: Accessing silverlight application throw outlook addin Pin
Mark Salsbery4-Feb-09 6:01
Mark Salsbery4-Feb-09 6:01 
QuestionTemplates for calendar control Pin
priyagee3-Feb-09 18:17
priyagee3-Feb-09 18:17 
AnswerRe: Templates for calendar control Pin
Mark Salsbery3-Feb-09 19:18
Mark Salsbery3-Feb-09 19:18 
QuestionIs there any native WPF Multiselect combobox available ? Pin
Member 57039053-Feb-09 8:19
Member 57039053-Feb-09 8:19 
AnswerRe: Is there any native WPF Multiselect combobox available ? Pin
JS 20084-Feb-09 3:17
JS 20084-Feb-09 3:17 
AnswerRe: Is there any native WPF Multiselect combobox available ? Pin
schiebel-t6-Feb-09 2:26
schiebel-t6-Feb-09 2:26 
QuestionSimple listbox stuff Pin
Ray Cassick3-Feb-09 7:22
Ray Cassick3-Feb-09 7:22 
AnswerRe: Simple listbox stuff Pin
Mark Salsbery3-Feb-09 15:14
Mark Salsbery3-Feb-09 15:14 
QuestionCan´t catch XamlParseException Pin
Czechtim3-Feb-09 1:01
Czechtim3-Feb-09 1:01 

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.