none
Click on DataTemplate in Blend RRS feed

  • Question

  • I have what I hope is a simple question about Blend.

    To demonstrate, create a new WPF app and paste this in the main grid:

            <ListBox>
                <ListBox.Resources>
                    <DataTemplate DataType="{x:Type sys:Double}">
                        <Rectangle Height="100" Width="200" Fill="Orange" Margin="10" />
                    </DataTemplate>
                    <DataTemplate DataType="{x:Type sys:String}">
                        <Rectangle Height="100" Width="200" Fill="Red" Margin="10" />
                    </DataTemplate>
                </ListBox.Resources>
                <ListBox.Items>
                    <sys:Double>1</sys:Double>
                    <sys:String>2</sys:String>
                </ListBox.Items>
            </ListBox>

    Now I want to click on the orange or red rectangle in the designer and I can not for the life of me figure out how.

    If I click on the orange rectangle, the outer ListBox is selected.

    If I right-click it and choose "Set Current Selection" my only options are to select the window or the listbox.

    If I right-click it and choose "Edit Additional Templates | Edit Generated Items (Item Template)" the sub menu option "Edit Current" is greyed out (which makes sense I guess since my ListBox doesn't have a specific ItemTemplate set).

    Now what I _can_ do is find that rectangle in the XAML source and click it there, and then it becomes selected in the design view as well, and and that point I can finally grab it and resize it or whatnot. So Blend definately has the power to edit the darn rectangle. But that sucks because it's likely to be off in some resource library somewhere. I just want to click it where it is on my screen, not figure out what data type it's being generated from and go hunting around for it in XAML.

    Anyone know?

    Friday, March 9, 2018 9:30 PM