Select to view content in your preferred language

Cannot populate XAML items in control that is contained within another control

1202
2
09-12-2010 08:50 AM
RyanCoodey
Frequent Contributor
I have a template control Bookmark (not the one from the ESRI toolkit), and in MainWindow.xaml, this works just fine:
<sdl:Bookmark>
    <sdl:Bookmark.Bookmarks>
        <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32">
        </sdl:BookmarkItem>
    </sdl:Bookmark.Bookmarks>
</sdl:Bookmark>


But, I also have a template control Titlebar which inside of its XAML contains one of these Bookmark controls, and in MainWindow.xaml, this does NOT work:
<sdl:Titlebar x:Name="Titlebar">
    <sdl:Titlebar.Bookmark>
        <sdl:Bookmark.Bookmarks> <!-- Doesn't like this -->
            <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32">
            </sdl:BookmarkItem>
        </sdl:Bookmark.Bookmarks>
    </sdl:Titlebar.Bookmark>
</sdl:Titlebar>


I get this error:

Error 11 The tag 'Bookmark.Bookmarks' does not exist in XML namespace 'clr-namespace:SDL.ArcGIS.Client.Toolkit;assembly=SDL.ArcGIS.Client.Toolkit'. Line 45 Position 22. C:\Projects\SDL.ArcGIS.Client.Toolkit\SDL.ArcGIS.Client.Toolkit.WPFTestApplication\MainWindow.xaml 45 22 SDL.ArcGIS.Client.Toolkit.WPFTestApplication

Bookmark does have a member property in the Titlebar class that is set to the template bookmark in OnApplyTemplate().  I tried making a dependency property for the Bookmark property too, but that didn't help either.

Is this a Known limitation?  Or most likley, what am I doing wrong?

Thanks a lot for any help!!!

*EDIT - Additional info:
Also, when doing the following, it compiles and launchs without error, but the BookmarkItems never appear in the ObservableCollection:
<sdl:Titlebar x:Name="Titlebar">
    <sdl:Titlebar.Bookmark>
        <sdl:Bookmark>
            <sdl:Bookmark.Bookmarks>
                <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32">
                </sdl:BookmarkItem>
            </sdl:Bookmark.Bookmarks>
        </sdl:Bookmark>
    </sdl:Titlebar.Bookmark>
</sdl:Titlebar>


Even though it compiles, this doesn't seem right to me though... having to redeclare the Bookmark.  It feels like a bookmark is being created inside a bookmark.
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
I'm guessing you need a collection type declared around the sdl:BoorkmarkItem (of whatever type Bookmark.Bookmarks
is). Something like (assuming the type is BookmarkItemCollection):
<sdl:BookmarkItemCollection>
<sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32" />
</sdl:BookmarkItemCollection>
0 Kudos
RyanCoodey
Frequent Contributor
of whatever type Bookmark.Bookmarks
is)


Bookmark.Bookmarks is an ObservableCollection<BookmarkItem>...

hmm, i know there are issues with ObservableCollection in xaml, not sure how to use it...  I tried making it a List too, but still not sure...

Thanks
0 Kudos