1
votes

This is my entire usercontrol xaml: Problem:The Combobox inside DataGrid named DG_Prices has a DataTemplate whose contentcontrol contains a Combobox.The ItemSource of this ComboBox is bound to a public property in Code Behind named LstAllPrices.ItemSource is not binding to to property named LstAllPrices which is a public property in code behind.

  <UserControl x:Class="Hexa.Screens.FrmItemDetail"
    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/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Hexa.Screens"
    mc:Ignorable="d"
    Height="535" Width="605">
<UserControl.Resources>

    <Style x:Key="TextBlockStyle" TargetType="{x:Type Border}">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="Beige"/>
    </Style>
    <Style TargetType="Label">
        <Setter Property="FontFamily" Value="Times new Roman"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Foreground" Value="DarkBlue"/>
    </Style>

    <Style TargetType="GroupBox">
        <Setter Property="Margin" Value="25,1,5,5"/>
        <Setter Property="Background" Value="LightGray"/>
        <Setter Property="BorderBrush" Value="#25A0DA"/>
        <Setter Property="BorderThickness" Value="0.5,0.4,0.4,0.4"/>
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding}" FontWeight="Bold" FontStyle="Italic" FontFamily="Palatino Linotype" FontSize="14" Foreground="DarkRed" />
                </DataTemplate>
            </Setter.Value>


        </Setter>
    </Style>

    <Style x:Name="Style_TextBox" TargetType="TextBox">
        <Setter Property="BorderBrush" Value="SkyBlue"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="FontFamily" Value="Times New Roman"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Height" Value="20"/>
    </Style>
</UserControl.Resources>
<Canvas  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="-315,-70">
    <TabControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Height="606" Width="1233" Canvas.Left="0" Background="LightGray">
        <TabItem Header="Main Information">
            <Canvas Height="400" Width="590" Margin="0,0,0,0">
                <Label Content="Code:" Canvas.Left="-198" Canvas.Top="-75"/>
                <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Top="-72" Canvas.Left="-76" />
                <Button Content="Filter" Canvas.Top="-74"   Width="105" FontWeight="Bold" Canvas.Left="-313" FontStyle="Italic"/>

                <Label Content="Creation Date:" Canvas.Top="-79" Canvas.Left="717" />
                <Label Content="POS menu Filter:" Canvas.Top="-79" Canvas.Left="285" />
                <Label Content="Production Date:" Canvas.Top="-81" Canvas.Left="505" />
                <DatePicker  Width="100" Canvas.Left="607" Canvas.Top="-81" x:Name="Dt_Prod_Date"   />
                <Label Content="Expiry Date:" Canvas.Top="-51" Canvas.Left="507" />
                <DatePicker  Width="100" Canvas.Left="608" Canvas.Top="-52" x:Name="Dt_Expiry_Date"   />

                <TextBox x:Name="txtPosMenuFilter" Width="115" Canvas.Top="-78" Canvas.Left="385"/>
                <Border Style="{StaticResource TextBlockStyle}" Canvas.Top="-72" Canvas.Left="830">
                    <TextBlock   Width="70" Canvas.Top="-40" Canvas.Left="-188" x:Name="txtCreationDate" Height="16" Background="White" />
                </Border>

                <Label Content="Last Updation Date:" Canvas.Top="-53" Canvas.Left="716" />
                <Border Style="{StaticResource TextBlockStyle}" Canvas.Top="-46" Canvas.Left="830" >
                    <TextBlock   Width="70" Canvas.Top="-40" Canvas.Left="-188" x:Name="txtUpdateDate" Height="16" Background="White"  />
                </Border>
                <Button Content="Generate Code" Canvas.Top="-74"  Background="Azure" Width="105" FontWeight="Bold" Canvas.Left="-38"/>
                <TextBox x:Name="txtAutoGen_Code" Width="79" Height="17" Background="White"  Canvas.Top="-72" Canvas.Left="-158" />
                <GroupBox Header="Button Properties" Height="285" Width="594"  Margin="0" Canvas.Top="-32" Canvas.Left="-313">
                    <Canvas>
                        <Label Content="Ticket description:" Margin="4,1,409,150"  />
                        <TextBox x:Name="txtDesc1" Width="195" Canvas.Left="115" Canvas.Top="7"  LostFocus="txtDesc1_LostFocus"/>
                        <Label Content="Second description:" Canvas.Left="3" Canvas.Top="27" />
                        <Label Content="Button sequence:" Canvas.Left="3" Canvas.Top="59" />
                        <ComboBox x:Name="cmbItem_Item_touch_scr_seq_2" Height="22" Canvas.Left="115" Canvas.Top="61" Width="46">
                            <ComboBoxItem Content="1"/>
                            <ComboBoxItem Content="2"/>
                            <ComboBoxItem Content="3"/>
                            <ComboBoxItem Content="4"/>
                            <ComboBoxItem Content="5"/>
                        </ComboBox>

                        <Label Content="UOM:" Canvas.Left="174" Canvas.Top="61" />
                        <ComboBox x:Name="cmbUOM" Width="92" Canvas.Left="218" Canvas.Top="62"/>
                        <TextBox x:Name="txtDesc2" Width="195"  Canvas.Left="115" Canvas.Top="31"/>
                        <Label Content="Button Template Settings:" Canvas.Left="28" Canvas.Top="102" />
                        <Label Content="Name:"  Width="56" Height="30" Canvas.Left="93" Canvas.Top="127"/>

                        <TextBox x:Name="txtItem_Name1" HorizontalAlignment="Right" Width="142" MaxLength="15" Text="NAME-1" Height="22"  Canvas.Left="153" Canvas.Top="130"  />
                        <TextBox x:Name="txtItem_Name2" HorizontalAlignment="Left" Width="142" MaxLength="15" Text="NAME-2" Height="22" Canvas.Left="153" Canvas.Top="158"/>
                        <Label Content="BackColor:" Margin="0" HorizontalAlignment="Left" Width="77" Height="25" Canvas.Left="26" Canvas.Top="187"/>
                        <local:UsrColorPicker  x:Name="cmbItem_Item_back_color"  HorizontalAlignment="Center" Width="224" Height="22"   SettingConfirmed="cmbItem_Item_back_color_SettingConfirmed"    Canvas.Left="101" Canvas.Top="187"    />
                        <Label Content="ForeColor:" Margin="0" Height="24" Canvas.Left="26" Canvas.Top="219" Width="75"/>
                        <local:UsrColorPicker   x:Name="cmbItem_Item_Fore_Color" HorizontalAlignment="Right" Width="223" Height="22" SettingConfirmed="cmbItem_Item_Fore_Color_SettingConfirmed"   Canvas.Left="102" Canvas.Top="219"   />
                        <GroupBox Height="241" Width="237" Background="DarkGray" Canvas.Left="336" Margin="0" Header="Button Template" Canvas.Top="1">
                            <Canvas>
                                <Button  Canvas.Left="42" Canvas.Top="29" Width="145" Height="150"  x:Name="cmdButtonTemplate"  Click="cmdButtonTemplate_Click"   Style="{StaticResource MyButton}">
                                    <ContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Height="131" Canvas.Left="10" Canvas.Top="10"    Width="142" >
                                        <Canvas x:Name="ContentCanvas">
                                            <Image  Canvas.Top="5" Canvas.Left="5"  x:Name="Button_Image"     />
                                            <TextBlock Canvas.Left="50" Canvas.Top="10"  Text="{Binding Text, ElementName=txtItem_Name1}"  Width="auto"        x:Name="Button_Text_1"/>
                                            <TextBlock Canvas.Left="50" Canvas.Top="70"  Text="{Binding Text, ElementName=txtItem_Name2}"   Width="auto"   x:Name="Button_Text_2"/>
                                        </Canvas>
                                    </ContentControl>
                                </Button>

                            </Canvas>
                        </GroupBox>
                    </Canvas>

                </GroupBox>
                <GroupBox Height="109" Width="254"  Margin="0" Header="Groups/Categories" Canvas.Top="252" Canvas.Left="-315">
                    <Canvas>
                        <Label Content="Group" Canvas.Top="12" Width="43" Canvas.Left="2"/>
                        <ComboBox x:Name="cmbGroupCode" Width="48"  Canvas.Left="55" Canvas.Top="13"  />
                        <TextBox x:Name="txtGroupName" Width="105"  Canvas.Left="106" Canvas.Top="13" IsReadOnly="True"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="213" Canvas.Top="15" x:Name="cmdSearchGroup" />

                        <Label Content="Category" Canvas.Top="48" Width="57" Canvas.Left="-1"/>
                        <ComboBox x:Name="cmbCategoryCode" Width="48"  Canvas.Left="55" Canvas.Top="48"  />
                        <TextBox x:Name="txtCategoryName" Width="105"  Canvas.Left="106" Canvas.Top="48" IsReadOnly="True"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="212" Canvas.Top="49" x:Name="cmdSearchCategory" />
                    </Canvas>
                </GroupBox>
                <GroupBox Height="109" Width="111" Margin="0" Canvas.Top="252"  Header="Bonus Schema" Canvas.Left="-58">
                    <Canvas>
                        <Label Content="Amount:" Canvas.Top="1" Width="55" Canvas.Left="9"/>
                        <TextBox x:Name="txtBonusAmount" Width="76"  Canvas.Left="12" Canvas.Top="22"/>
                        <Label Content="Bonus:" Canvas.Top="38" Width="43" Canvas.Left="10"/>
                        <TextBox x:Name="txtBonus" Width="76"  Canvas.Left="13" Canvas.Top="58"/>
                    </Canvas>
                </GroupBox>
                <GroupBox Width="226" Height="109"  Margin="0" Canvas.Top="252" Header="Modifiers" Canvas.Left="55">
                    <Canvas>
                        <TextBox x:Name="txtModCode1" Width="48"  Canvas.Left="2" Canvas.Top="1" Height="17"/>
                        <TextBox x:Name="txtModname1" Width="119"  Canvas.Left="60" Canvas.Top="1" Height="17"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="183" Canvas.Top="3" x:Name="cmdSearchMod1" />

                        <TextBox x:Name="txtModCode2" Width="48"  Canvas.Left="2" Canvas.Top="23" Height="17"/>
                        <TextBox x:Name="txtModname2" Width="117"  Canvas.Left="60" Canvas.Top="23" Height="17"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="182" Canvas.Top="26" x:Name="cmdSearchMod2" />

                        <TextBox x:Name="txtModCode3" Width="48"  Canvas.Left="2" Canvas.Top="45" Height="17"/>
                        <TextBox x:Name="txtModname3" Width="117"  Canvas.Left="60" Canvas.Top="45" Height="17"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="182" Canvas.Top="47" x:Name="cmdSearchMod3" />

                        <TextBox x:Name="txtModCode4" Width="48"  Canvas.Left="2" Canvas.Top="66" Height="17"/>
                        <TextBox x:Name="txtModname4" Width="116"  Canvas.Left="60" Canvas.Top="66" Height="17"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="182" Canvas.Top="67" x:Name="cmdSearchMod4" />
                    </Canvas>
                </GroupBox>
                <GroupBox Height="126" Width="596"  Margin="0" Canvas.Top="356" Canvas.Left="-315" Header="Pricing">
                    <DataGrid VerticalScrollBarVisibility="Visible" x:Name="Dg_Prices" CanUserReorderColumns="True" CanUserResizeColumns="False" CanUserResizeRows="False" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Header="Price name">
                                <DataGridTemplateColumn.CellTemplate >
                                    <DataTemplate>
                                        <DataGridCell>
                                            <ContentControl>
                                                <ComboBox DataContext="{Binding RelativeSource={RelativeSource Self}}"
                                            ItemsSource="{Binding LstAllPrices}"
                                            />
                                            </ContentControl>
                                        </DataGridCell>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Header="Price Point">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <DataGridCell>
                                            <ContentControl>
                                                <TextBox Width="100" Text="{Binding PriceName}" x:Name="AmountColumn"  />
                                            </ContentControl>
                                        </DataGridCell>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>

                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </GroupBox>
                <GroupBox Height="125" Width="620"  Canvas.Left="285" Margin="0" Header="Inventory Information" Canvas.Top="-33">
                    <Canvas Margin="3,0,-3,0">
                        <Label Content="Supplier:" Canvas.Left="8" Canvas.Top="-2" />
                        <TextBox x:Name="txtSupplierId" Width="62" Canvas.Left="115" Canvas.Top="1"/>
                        <TextBox x:Name="txtSupplierName" Width="340" Canvas.Left="191" Canvas.Top="1"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="533" Canvas.Top="2" />
                        <Label Content="Purchase price:" Canvas.Top="22" Canvas.Left="7" />
                        <TextBox x:Name="txtSupplierPrice" Width="62" Canvas.Left="115" Canvas.Top="25"/>
                        <Label Content="VAT Code:" Canvas.Top="25" Canvas.Left="263" />
                        <TextBox x:Name="txtSupplierVAT" Width="90" Canvas.Left="372" Canvas.Top="25"/>
                        <Image  Source="/Hexa;component/Images/SEARCH.png"  Width="25" Height="18" Canvas.Left="469" Canvas.Top="26" />
                        <Label Content="15.00%" Canvas.Top="24" Width="51" Canvas.Left="491" FontWeight="Thin" x:Name="lblSupplier_Vat_Percentage"/>
                        <Label Content="Average Cost price:" Canvas.Top="48" Canvas.Left="5" />
                        <Label Content="Quantity in hand:" Canvas.Top="49" Canvas.Left="261" />
                        <TextBox x:Name="txtAvgCostPrice" Width="62" Canvas.Left="115" Canvas.Top="49"/>
                        <TextBox x:Name="txtCurrent_Qty" Width="55" Canvas.Left="373" Canvas.Top="49"/>
                        <Label Content="Minimum Stock:" Canvas.Top="75" Canvas.Left="6" />
                        <TextBox x:Name="txtMinStock" Width="62" Canvas.Left="115" Canvas.Top="74"/>
                        <Label Content="Maximum Stock:" Canvas.Top="73" Canvas.Left="262" />
                        <TextBox x:Name="txtMaxStock" Width="90" Canvas.Left="373" Canvas.Top="74"/>
                    </Canvas>
                </GroupBox>
                <GroupBox Height="166" Width="619"  Canvas.Left="286" Margin="0" Canvas.Top="89" Header="Offers">
                    <Canvas>

                        <GroupBox Height="153" Width="191"  Margin="0" Canvas.Top="-14" >
                            <Canvas Margin="0,0,0,-16">
                                <Label Content="Line discount" Canvas.Left="-3" Canvas.Top="-9"/>
                                <TextBox x:Name="txtLineDiscount" Width="76"  Canvas.Left="77" Canvas.Top="-5" MaxLength="14"/>
                                <Label Content="Beginning:" Canvas.Top="18" Canvas.Left="11"/>
                                <DatePicker  Width="100" Canvas.Left="77" Canvas.Top="19" x:Name="Dt_line_Disc_Begin_Date"  />
                                <Label Content="Till:" Canvas.Top="46" Canvas.Left="11"/>
                                <DatePicker  Width="100" Canvas.Left="77" Canvas.Top="48" x:Name="Dt_line_Disc_End_Date"   />
                                <Label Content="Future selling price:" Canvas.Top="74" Canvas.Left="11"/>
                                <TextBox x:Name="txtFuture_Price_Sell" Width="53"  Canvas.Left="124" Canvas.Top="77"/>
                                <Label Content="Activate on:" Canvas.Top="102" Canvas.Left="9"/>
                                <DatePicker  Width="99" Canvas.Left="78" Canvas.Top="101" x:Name="Dt_line_Disc_Activation_Date"   />
                            </Canvas>
                        </GroupBox>
                        <GroupBox Height="153" Width="412"  Canvas.Left="195" Margin="0" Canvas.Top="-14" >
                            <Canvas>
                                <Label Content="Specific time price:" Canvas.Left="-3" Canvas.Top="3"/>
                                <TextBox x:Name="txtFuture_Selling_Price" Width="62"  Canvas.Left="124" Canvas.Top="5"/>
                                <Label Content="Activate on:" Canvas.Left="215" Canvas.Top="3"/>
                                <DatePicker  Width="99" Canvas.Left="296" Canvas.Top="3" x:Name="Dt_Spec_Time_Price_Activation_Date"   />
                                <Label Content="Price on specific hours:" Canvas.Left="-3" Canvas.Top="31"/>
                                <TextBox x:Name="txtSpecific_Hour_Price" Width="61"  Canvas.Left="125" Canvas.Top="31"/>
                                <Label Content="From Time:" Canvas.Left="-3" Canvas.Top="69"/>
                                <ComboBox x:Name="cmb_Specific_Time_Price_From_Hour" Canvas.Top="71" Canvas.Left="67"/>
                                <ComboBox x:Name="cmb_Specific_Time_Price_From_Minute" Canvas.Top="71" Canvas.Left="94"/>
                                <Label Content="Till Time:" Canvas.Top="99" Canvas.Left="-3"/>
                                <ComboBox x:Name="cmb_Specific_Time_Price_Till_Hour" Canvas.Top="99" Canvas.Left="68"/>
                                <ComboBox x:Name="cmb_Specific_Time_Price_Till_Minute" Canvas.Top="99" Canvas.Left="95"/>
                                <Label Content="Order Qty:" Canvas.Top="70" Canvas.Left="136"/>
                                <TextBox x:Name="txtOrder_Qty" Width="47"  Canvas.Left="200" Canvas.Top="72"/>
                                <Label Content="Free Qty:" Canvas.Top="97" Canvas.Left="137"/>
                                <TextBox x:Name="txtFree_Qty" Width="47"  Canvas.Left="200" Canvas.Top="99"/>
                                <Label Content="From:" Canvas.Top="71" Canvas.Left="257"/>
                                <DatePicker  Width="99" Canvas.Left="298" Canvas.Top="69" x:Name="Dt_Specific_Time_Price_From_Date"   />
                                <Label Content="Till:" Canvas.Top="98" Canvas.Left="259"/>
                                <DatePicker  Width="99" Canvas.Left="298" Canvas.Top="97" x:Name="Dt_Specific_Time_Price_Till_Date"   />
                            </Canvas>
                        </GroupBox>
                    </Canvas>
                </GroupBox>

                <GroupBox Height="228" Width="327"  Canvas.Left="286" Margin="0" Canvas.Top="253" Header="Miscelleneous Options">
                    <Canvas>
                        <Label Content="OUT of Sales Panel" Canvas.Top="12" Canvas.Left="7"/>
                        <CheckBox x:Name="chkOut_Of_Sales" Canvas.Left="138" Canvas.Top="18"/>

                        <Label Content="OUT of STOCK Panel" Canvas.Top="53" Canvas.Left="6" />
                        <CheckBox x:Name="chkOut_Of_Stock" Canvas.Left="291" Canvas.Top="19"/>

                        <Label Content="Open price" Canvas.Top="12" Canvas.Left="192" />
                        <CheckBox x:Name="chkOpen_Price" Canvas.Left="138" Canvas.Top="57"/>

                        <Label Content="Open Description" Canvas.Top="81" Canvas.Left="190"  />
                        <CheckBox x:Name="chkOpenDesc" Canvas.Left="291" Canvas.Top="54"/>

                        <Label Content="Non Stock" Canvas.Top="48" Canvas.Left="192" />
                        <CheckBox x:Name="chkNon_Stock" Canvas.Left="138" Canvas.Top="91"/>

                        <Label Content="Weighable" Canvas.Top="87" Canvas.Left="5" />
                        <CheckBox x:Name="chkWeighable" Canvas.Left="292" Canvas.Top="87"/>

                        <Label Content="No Discount" Canvas.Top="116" Canvas.Left="195" />
                        <CheckBox x:Name="chkNo_Discount" Canvas.Left="293" Canvas.Top="121"/>

                        <Label Content="Show price on button" Canvas.Top="123" Canvas.Left="5" />
                        <CheckBox x:Name="chkShow_Price_On_Button" Canvas.Left="138" Canvas.Top="128"/>

                        <Label Content="Modification AutoOpen" Canvas.Top="161" Canvas.Left="6" />
                        <CheckBox x:Name="chkModification_Auto_Open" Canvas.Left="138" Canvas.Top="167"/>

                    </Canvas>
                </GroupBox>

                <GroupBox Height="217" Width="287"  Canvas.Left="618" Margin="0" Canvas.Top="255" Header="Active Printer">
                    <Canvas>
                        <ListBox x:Name="lstprinters" Height="190" Width="275" FontFamily="Sans Serif" FontSize="22">
                            <ListBoxItem Content="Printer-1"/>
                            <ListBoxItem Content="Printer-2"/>
                            <ListBoxItem Content="Printer-3"/>
                            <ListBoxItem Content="Printer-4"/>
                            <ListBoxItem Content="Printer-5"/>
                            <ListBoxItem Content="Printer-6"/>
                            <ListBoxItem Content="Printer-7"/>
                            <ListBoxItem Content="Printer-8"/>
                        </ListBox>
                    </Canvas>
                </GroupBox>
            </Canvas>
        </TabItem>


    </TabControl>

    <Image Source="..\Images\FIRST-RECORD.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="317"  />
    <Image Source="..\Images\PREVIOUS_RECORD.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="384" />
    <Image Source="..\Images\NEXT_RECORD.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="448" />
    <Image Source="..\Images\LAST_RECORD.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="515" />
    <Image Source="..\Images\ADD_RECORD.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="598" />
    <Image Source="..\Images\edit.png" Height="55" Canvas.Top="615" Canvas.Left="660" />
    <Image Source="..\Images\delete.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="723" />
    <Image Source="..\Images\save.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="811" x:Name="cmdSave" MouseUp="cmdSave_MouseUp" />
    <Image Source="..\Images\edit.png" Height="55" Width="55" Canvas.Top="615" Canvas.Left="874"  />
    <Image Source="..\Images\exit.png" Height="55" Width="55"  x:Name="cmdExit" MouseUp="cmdExit_MouseUp" Canvas.Left="937" Canvas.Top="615"/>



</Canvas>

code behind is:

    using Hexa.Global;
using Hexa.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPF.MDI;

namespace Hexa.Screens
{

    public partial class FrmItemDetail : UserControl
    {

        DC_ItemDetails DCIM;
        private List<string> _LstAllPrices;
        public List<string> LstAllPrices
        {
            get
            {
                if (_LstAllPrices == null)
                {
                    _LstAllPrices = new List<string>();
                    _LstAllPrices = DCIM.Lst_Prices.Select(item => item.PriceName).ToList<string>();
                }
                return _LstAllPrices;
            }
            set
            {
                if(_LstAllPrices==null)
                {
                    _LstAllPrices = value;

                }

            }
        }

        public FrmItemDetail()
        {
            InitializeComponent();
             DCIM = new DC_ItemDetails();
            this.DataContext = DCIM;
            cmbGroupCode.ItemsSource = DCIM.Lst_Button_Details.Where(item => item.Button_Template_Type.Equals("Group", StringComparison.Ordinal)).Select(item => item.Button_Template_Id).ToList<int>();
            cmbUOM.ItemsSource = DCIM.Lst_UOM.Select(item => item.UOM).ToList<string>();
           Dg_Prices.ItemsSource = this.DCIM.Lst_Prices;
        }


}
}

Getting following error in output window:

System.Windows.Data Error: 40 : BindingExpression path error: 'LstAllPrices' property not found on 'object' ''ListView' (Name='')'. BindingExpression:Path=LstAllPrices; DataItem='ListView' (Name=''); target element is 'ListView' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')

1
MyList must be a property of something. What is it a property of? Is it a property of the row item? Of the main viewmodel? Of the window?15ee8f99-57ff-4f92-890c-b56153
What exactly is "this View"? Probably a UserControl or Window but you need to clarify.grek40
@grek40:this view is a usercontrol and MyList<string> is a public property in the viewJatinder Walia
See the bottom of my answer there, it's the same solution for your case: stackoverflow.com/a/44497020/5265292 (though the question is different)grek40
@Ed Plunkett:tx for the pointer there,but this is just an R&D thing,so was doing something else when u asked me to copy paste the whole thing and i copied it..Otherwise,yea i wud never do that...Databinding,and especially comboboxes in WPF is taking some time for me to master,but with the support of such a rich and helpful online community,i will.tx Ed. :-).Jatinder Walia

1 Answers

2
votes

If MyList is a public property of the parent UserControl that returns a List<string>, you should be able to bind to it like this:

<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <ComboBox ItemsSource="{Binding MyList, RelativeSource={RelativeSource AncestorType=UserControl}}"  />
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>