XAML
<Button x:Name="bt_show" Grid.Row="5" Grid.Column="1" Content="조회" Margin="10" Command="{Binding GetCodeListByMarketCommand}"> <Button.CommandParameter> <MultiBinding Converter="{StaticResource ParamToStringAxKHConverter}"> <Binding ElementName="cb_market_type" Path="SelectedValue" /> <Binding ElementName="axKHOpenAPI" /> </MultiBinding> </Button.CommandParameter> </Button>
Converter
public class StringAxKH { public string _str; public AxKHOpenAPI _axKHOpenAPI; public StringAxKH(string str, AxKHOpenAPI axKHOpenAPI) { _str = str; _axKHOpenAPI = axKHOpenAPI; } public StringAxKH(object str, object axKHOpenAPI) { _str = str as string; _axKHOpenAPI = axKHOpenAPI as AxKHOpenAPI; } } public class ParamToStringAxKHConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { return new StringAxKH(values[0], values[1]); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
Command Execution Logic
#region [Command] GetCodeListByMarketCommand public RelayCommand<Converter.StringAxKH> GetCodeListByMarketCommand { get { return _getCodeListByMarketCommand ?? (_getCodeListByMarketCommand = new RelayCommand<Converter.StringAxKH>( (objStringAxKH) => { AxKHOpenAPI axKHOpenAPI = objStringAxKH._axKHOpenAPI; string sMarket = objStringAxKH._str; CodeList = new Kiwoom.KiwoomHelper(axKHOpenAPI).GetCodeListByMarket(sMarket); } )); } } #endregion
Passing two command parameters using a WPF binding
stack overflow
WPF pass multiple parameters to command (closed)
stack overflow