How to display values from the combo box in wpf ui?

gciraman2024

Member
Joined
May 19, 2024
Messages
12
Programming Experience
3-5
Hi Team

I have a combo box but the problem, the data is only showing on the grid and on the rectangle, when i try to select from the combo box itself there is nothing to see where the problem is.
XML:
<!---Stock code variable holder-->
    <UserControl.Resources>
        <CollectionViewSource x:Key="StockCodes" Source="{Binding StockCodes}"/>
        <CollectionViewSource x:Key="StockDescription" Source="{Binding Description}"/>
    </UserControl.Resources>
   
    <Grid Background="White" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,86,-775.6,-46.6" Width="1766">
        <Label Content="Premix Material Management" BorderThickness="1.5" BorderBrush="#FF0B0B0B" Background="#FF383838" Foreground="White" FontSize="18" HorizontalContentAlignment="Center" VerticalAlignment="Top" Margin="10,10,0,0" FontWeight="SemiBold" />
        
        <!---Rectangle for Recipe Details-->
        <Rectangle  HorizontalAlignment="Left" Height="371" Stroke="#FFCFCFD1" VerticalAlignment="Top" Width="260" Margin="14,104,0,0"/>
       
       
        <!---Recipe fields-->
        <Label Content="Recipe Details" FontWeight="SemiBold"  HorizontalAlignment="Left" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="260" BorderBrush="#FFBEBEBE" Background="#FFE3E3E3" BorderThickness="1.5" Foreground="Black" Height="30" VerticalContentAlignment="Center" FontSize="12" Margin="14,103,0,0"/>
        <Label x:Name="lblActive_Copy9" FontWeight="SemiBold" FontSize="10" Visibility="Visible" Content="IDX:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,135,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtIDX" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" FontSize="10" Height="26" Margin="146,132,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy1" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Recipe:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,163,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtRecipe" Foreground="Black" FontSize="10" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,160,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy13" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Rec No:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,191,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtRecNo" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,188,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy2" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Description:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,220,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtDescription" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,217,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy3" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Batch Size:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,248,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtBatchSize" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,245,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy4" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Palleting Instruction:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,276,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtPalletInstruction" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,273,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy5" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Feed First Recipe Name:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,304,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtFeedFirstName" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,301,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy11" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="PPA TK601:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,331,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtPPATK601" ToolTip="Can only be edit if second last digit in recipe is 2"  IsReadOnly="True" TextChanged="txtPPATK601_TextChanged" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,328,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy12" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="PPA TK602:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,359,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <TextBox x:Name="txtPPATK602" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="26" Margin="146,354,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy10" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Active:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,387,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <CheckBox x:Name="chkActive" TabIndex="3" HorizontalAlignment="Left" Checked="chkActive_Checked" Unchecked="chkActive_Unchecked" Margin="146,392,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.043,-1.119"/>
        <Button x:Name="btnAdd_Copy" Content="Save" Click="btnAdd_Click"  Background="ForestGreen" BorderBrush="ForestGreen" FontWeight="SemiBold" Visibility="Visible" HorizontalAlignment="Left" Margin="176,415,0,0" VerticalAlignment="Top" Width="90" />


       
        <!---Ingredient Totals-->
        <Rectangle  HorizontalAlignment="Left" Height="371" Stroke="#FFCFCFD1" VerticalAlignment="Top" Width="270" Margin="290,103,0,0"/>
        <Label Content="Ingredient Totals" FontWeight="SemiBold" HorizontalAlignment="Left" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="270" BorderBrush="#FFBEBEBE" Background="#FFE3E3E3" BorderThickness="1.5" Foreground="Black" Height="29" VerticalContentAlignment="Center" FontSize="12" Margin="288,104,0,0"/>
       
        <!---Ingredient fields names-->
        <Label x:Name="lblActive_Copy" FontWeight="SemiBold" Visibility="Visible" Content="Micros:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="124" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="296,135,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE" Height="23" FontSize="10"/>
        <TextBox x:Name="txtMicroTotal" FontSize="10" Foreground="Black" HorizontalAlignment="Left" Visibility="Visible" Height="20" Margin="425,138,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Label x:Name="lblActive_Copy7" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Macros:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="125" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="296,163,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE" Height="23"/>
        <TextBox x:Name="txtMacroTotal" Foreground="Black" FontSize="10" HorizontalAlignment="Left" Visibility="Visible" Height="23" Margin="426,163,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="122"/>
        <Label x:Name="lblActive_Copy8" FontSize="10" FontWeight="SemiBold" Visibility="Visible" Content="Total:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="125" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="295,191,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE" Height="23"/>
        <TextBox x:Name="txtTotal" Foreground="Black" FontSize="10" HorizontalAlignment="Left" Visibility="Visible" Height="23" Margin="426,191,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="122"/>


        <!---Recipe name and drop down box-->
        <Label x:Name="lblDriverName_Copy" FontWeight="SemiBold" Visibility="Visible" Content="Recipe Code:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="179" HorizontalContentAlignment="Right" Background="#FFE3E3E3" Margin="17,65,0,0" BorderThickness="1" BorderBrush="#FFBEBEBE"/>
        <ComboBox x:Name="cbxRecipe" TabIndex="1" IsTextSearchEnabled="True"  ItemsSource="{Binding Recipe}" DisplayMemberPath="StockCodes"  IsEditable="True"    IsTextSearchCaseSensitive="False"  Foreground="Black" HorizontalAlignment="Left" Margin="207,63,0,0" VerticalAlignment="Top" Width="214" SelectionChanged="cbxRecipe_SelectionChanged">
            <ComboBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>
            </ComboBox.ItemsPanel>
        </ComboBox>
 

Attachments

  • Screenshot 2024-06-24 150204.png
    Screenshot 2024-06-24 150204.png
    112.5 KB · Views: 15
Last edited by a moderator:
What happens when you remove lines 56-60?
 
Back
Top Bottom