batshit

batshit

  • NA
  • 1
  • 0

combobox binding json values

May 12 2013 5:39 PM
Hello, I seem to be having an issue with, not knowing how to make a proper binding in WPF.
I have the combobox displaying the proper  DisplayName but on selection the value sent is not what is the text in the combo box selection

Here is my combobox

<se:MyComboBox x:Name="AssetLibrarySetName"
                           Grid.Row="0"
                           Grid.Column="1"
                           IsEditable="true"
                           ItemsSource="{Binding Path=DownloadablePackages}"
                           Text="{Binding Path=AssetLibrarySetName, UpdateSourceTrigger=PropertyChanged}">
                 <ComboBox.ItemTemplate>
                        <DataTemplate DataType="GameInfo:DownloadablePackageDefinition">
                                <Label Content="{Binding Path=DisplayName}"/>
                        </DataTemplate>
                </ComboBox.ItemTemplate>
</se:MyComboBox>



Here is the asset code on




public string AssetLibrarySetName
{
get
{
if (this.AssetLibrarySetId == 0)
{
return "Base Game";
}

var package = InfoManager.DownloadablePackages.Items
.Select(kv => kv.Value)
.FirstOrDefault(dp => dp.Id == this.AssetLibrarySetId);
if (package == null)
{
return string.Format("(unknown #{0})", this.AssetLibrarySetId);
}

return string.Format("{1} (#{0})",
this.AssetLibrarySetId,
package.DisplayName);
}

set
{
this.AssetLibrarySetName = value;
if (this.AssetLibrarySetName == "Base Game" )
{
this.AssetLibrarySetId = 0;
}
var package = InfoManager.DownloadablePackages.Items
.Select(kv => kv.Value)
.FirstOrDefault(dp => dp.DisplayName == this.AssetLibrarySetName);
if (package == null)
{
this.AssetLibrarySetId = 0;
}
else
{
this.AssetLibrarySetId = package.Id;
}
}
}

On click the Label Content="{Binding Path=DisplayName}" needs to be sent and its sending "GameInfo.DownloadablePackageDefinition"

what am I missing?