I have a WPF/C# app with a tiny issue. I have a label that is passing the string value of AZ. I have a combobox that has AX, AY, and AZ values bound to the database. For some reason, the label value is not matching to the combobox value.
So, I have
CbCode.SelectedValue = Code;
Code is coming from another window
public SystemCode(string Code)
{
InitializeComponent();
Code = sysCode;
}
public string Code { get; }
The debugger tells me the string value is AZ, bu the combobox in the screen is the default the value of AX.
So how do I get the label content to set the page load value of the combobox?
XAML:
<ComboBox x:Name="CbCode" DataContext="{StaticResource CodeViewSource}"
SelectedValuePath="Code" ItemsSource="{Binding}" DisplayMemberPath="Code"
HorizontalAlignment="Left" Margin="106,103,0,116.4" Width="97"
d:LayoutOverrides="Height"/> <TextBox x:Name="TxtZipFive"
HorizontalAlignment="Left" Height="23" Margin="106,0,0,85.4"
TextWrapping="Wrap" Text="" VerticalAlignment="Bottom" Width="97"/>
您的问题还不够清楚,但我认为您需要使用:
UpdateSourceTrigger=PropertyChanged
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.