Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Binding Problem in ComboBox

 
 
Old 09-13-2007   #1 (permalink)
Horst Klein


 
 

Binding Problem in ComboBox

Hi

I try to bound the ComboBox (x:Name="Search_fld_FieldName") to the Property
"Name" of my "SelectableFields" Object (see <DataTemplate
x:Key="FieldItemsTemplate">).

The "Value" will be shown in the TextBox.
But the "Name" of my SearchField-Elements ist not show in the ComboBox:
<VitoSearchBox:SearchField Name="Name" Default="True" Value="Morbus"/>

The Elements in the "SelectableFields" Colletion are visible if DropDownOpend.
In Expression Blend I tryed different ways to make the Name visible in the
ComboBox.
But without success.

Can you tell me what I'm doing wrong.



My XAML:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:VitoSearchBox="clr-namespace:VitoSearchBox"
x:Class="VitoSearchBox"
x:Name="VitoSearchBox"
Width="195" Height="500" Background="#FFFFFFFF" MinWidth="200">

<UserControl.Resources>

<VitoSearchBox:SearchTables x:Key="mySearchTablesDatas">
<VitoSearchBox:SearchTable Name="Patient">
<VitoSearchBox:SearchField Name="Name" Default="True" Value="Morbus"/>
<VitoSearchBox:SearchField Name="Vorname" Default="True"
Value="Hugo" />
<VitoSearchBox:SearchField Name="Strasse"/>
<VitoSearchBox:SearchField Name="Postleitzahl"/>
<VitoSearchBox:SearchField Name="Ort"/>
</VitoSearchBox:SearchTable>
<VitoSearchBox:SearchTable Name="Lieferant">
<VitoSearchBox:SearchField Name="Sugus" Default="True"/>
<VitoSearchBox:SearchField Name="Otto" Default="True"/>
<VitoSearchBox:SearchField Name="Essig"/>
<VitoSearchBox:SearchField Name="Duhgfgug"/>
</VitoSearchBox:SearchTable>
<VitoSearchBox:SearchTable Name="Artikel">
<VitoSearchBox:SearchField Name="Name" Default="True"/>
<VitoSearchBox:SearchField Name="Nummer" Default="True"/>
<VitoSearchBox:SearchField Name="Menge" Default="True"/>
<VitoSearchBox:SearchField Name="Hersteller"/>
<VitoSearchBox:SearchField Name="Lagermenge"/>
</VitoSearchBox:SearchTable>
</VitoSearchBox:SearchTables>

<DataTemplate x:Key="FieldItemsTemplate">
<Grid HorizontalAlignment="Right" Width="Auto" Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="113"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ComboBox
SelectedValue="{Binding Path=SelectableFields, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={StaticResource mySearchTablesDatas},
Path=SelectableFields, Mode=Default, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Name"
x:Name="Search_fld_FieldName"
MinWidth="90" HorizontalContentAlignment="Stretch" Padding="0,0,0,0"
Grid.ColumnSpan="1"
Margin="-2,0,0,0"
Text="{Binding Path=[Name], Mode=OneWay}"
/>
<TextBox HorizontalAlignment="Stretch" Width="75" Grid.Column="1"
Text="{Binding Path=Value, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</DataTemplate>

</UserControl.Resources>

<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="0.936*"/>
<RowDefinition Height="0.064*"/>
<RowDefinition Height="4.8"/>
<RowDefinition Height="71" MinHeight="100"/>
</Grid.RowDefinitions>

<GridSplitter HorizontalAlignment="Stretch" Grid.Row="2" Margin="0,0,0,0"/>

<ListBox x:Name="mySearchTables" VerticalAlignment="Top" Height="131"
ScrollViewer.CanContentScroll="True"
DisplayMemberPath="Name" IsSynchronizedWithCurrentItem="True"
SelectionChanged="SelectedSearchTableChanged"
ItemsSource="{Binding Source={StaticResource mySearchTablesDatas},
Mode=Default}"
/>

<ListBox Margin="0,131,0,25" x:Name="SearchCriterias"
IsSynchronizedWithCurrentItem="True"
ItemTemplate="{DynamicResource FieldItemsTemplate}"
Grid.RowSpan="2"
ItemsSource="{Binding Source={StaticResource mySearchTablesDatas},
Path=SearchFields, Mode=Default}" IsTextSearchEnabled="False"

/>

<ListView x:Name="SearchResult" Grid.Row="3"
IsSynchronizedWithCurrentItem="True">
<ListView.View>
<GridView>
<GridViewColumn Header="GridViewColumn"/>
</GridView>
</ListView.View>
</ListView>

<Button Style="{DynamicResource SimpleButton}" Height="25" Width="50"
Content="Search" BorderThickness="1,1,1,1" RenderTransformOrigin="0.44,0.477"
d:LayoutOverrides="Height" HorizontalAlignment="Right" Margin="0,0,0,0"
VerticalAlignment="Bottom" Grid.RowSpan="2" x:Name="btnSearch"
Click="Search"/>
<Button Style="{DynamicResource SimpleButton}" Height="25" Width="25"
Content="/\" BorderThickness="1,1,1,1" RenderTransformOrigin="0.483,0.462"
d:LayoutOverrides="Height" HorizontalAlignment="Left" Margin="0,0,0,0"
VerticalAlignment="Bottom" Grid.RowSpan="2" x:Name="btnUp"/>
<Button Style="{DynamicResource SimpleButton}" Height="25" Width="25"
Content="\/" BorderThickness="1,1,1,1" RenderTransformOrigin="0.483,0.462"
d:LayoutOverrides="Height" HorizontalAlignment="Left" Margin="25,0,0,0"
VerticalAlignment="Bottom" Grid.RowSpan="2" x:Name="btnDown"/>
<Button Style="{DynamicResource SimpleButton}" Height="25" Width="25"
Content="CLR" BorderThickness="1,1,1,1" RenderTransformOrigin="0.44,0.477"
d:LayoutOverrides="Height" HorizontalAlignment="Left" Margin="54,0,0,0"
VerticalAlignment="Bottom" Grid.RowSpan="2" x:Name="btnClear"
Click="ClearSearchFields"/>
<Button Style="{DynamicResource SimpleButton}" Height="25" Width="25"
Content="DEL" BorderThickness="1,1,1,1" RenderTransformOrigin="0.44,0.477"
d:LayoutOverrides="Height" HorizontalAlignment="Left" Margin="83,0,88,0"
VerticalAlignment="Bottom" Grid.RowSpan="2" x:Name="btnDelete"
Click="DeleteSearchField"/>
<Button Style="{DynamicResource SimpleButton}" Height="25" Width="25"
Content="INS" BorderThickness="1,1,1,1" RenderTransformOrigin="0.44,0.477"
d:LayoutOverrides="Height" HorizontalAlignment="Left" Margin="112,0,0,0"
VerticalAlignment="Bottom" Grid.RowSpan="2" x:Name="btnInsert"
Click="InsertSearchField"/>
</Grid>
</UserControl>


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
binding to combobox itemssource? .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46