Combobox selected itemdoes not display proper value

Docking/MDI for WPF Forum

Posted 10 years ago by Pratik
Version: 4.5.0484
Platform: .NET 3.5
Environment: Windows XP (32-bit)
Avatar
hi,

i am using Above actipro version and i want to display list of toolwindows in my combobox.


what i am doing is i am just replacing the code

<ListBox x:Name="toolWindowsListBox" Margin="0,3,0,0" Height="150" ItemsSource="{Binding ElementName=dockSite, Path=ToolWindows}" SelectedIndex="1">
                            <ListBox.ItemTemplate>
                                <DataTemplate DataType="docking:ToolWindow">
                                    <TextBlock x:Name="title" Text="{Binding Title}" />
                                    
                                    <DataTemplate.Triggers>
                                        <DataTrigger Binding="{Binding IsOpen}" Value="True">
                                            <Setter TargetName="title" Property="FontWeight" Value="Bold" />
                                        </DataTrigger>
                                    </DataTemplate.Triggers>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
Of File MainWindow.xaml of Programatically creating toolwindow sample code of doking given by your sample project

with following lines

<ComboBox x:Name="toolWindowsListBox" Margin="0,3,0,0" Height="150" ItemsSource="{Binding ElementName=dockSite, Path=ToolWindows}" SelectedIndex="1">
                            <ComboBox.ItemTemplate>
                                <DataTemplate DataType="docking:ToolWindow">
                                    <TextBlock x:Name="title" Text="{Binding Title}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>

as per above code combobox should show list of toolwindows and when selected it should show title of selected toolwindow but it is showing some thing else..
please help me in these topic how can i fix these issue.

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Pratik,

The WPF ComboBox has a SelectionBoxItemTemplate property you'd want to set too. Its ItemTemplate is only used in the dropdown.


Actipro Software Support

Posted 10 years ago by Pratik
Avatar
Hi,
While trying with following xaml code

<ComboBox x:Name="toolWindowsListBox" Margin="0,3,0,0" Height="150" ItemsSource="{Binding ElementName=dockSite, Path=ToolWindows}" SelectedIndex="1">
                            <ComboBox.ItemTemplate>
                                <DataTemplate DataType="docking:ToolWindow">
                                    <TextBlock x:Name="title" Text="{Binding Title}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                            <ComboBox.SelectionBoxItemTemplate>
                                <DataTemplate DataType="docking:ToolWindow">
                                    <TextBlock x:Name="title" Text="{Binding Title}" />
                                </DataTemplate>
                            </ComboBox.SelectionBoxItemTemplate>
                        </ComboBox>

it gives following error message it states that you can't set this property


Error 1 The property 'ComboBox.SelectionBoxItemTemplate' cannot be set because it does not have an accessible set accessor. Line 67 Position 30.
xaml 67 30 SampleApplication-CSharp.VS2008


please help me in this thing.

thanx in advance
regards,
pratik
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Pratik,

Whoops, sorry you are right. Now I remember, this was a bad design by Microsoft not making it easily customizable. There are several posts like this with a workaround though:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/59c6879b-ba9e-4372-bc1d-8224cd3ff768


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.