@@ -348,22 +348,28 @@ private void PropertyNameTextBox_GotFocus(object sender, RoutedEventArgs e)
348348 private void SelectTypeMenuItem_Click ( object sender , RoutedEventArgs e )
349349 {
350350 var me = ( MenuItem ) sender ;
351- if ( me . GetType ( ) == typeof ( ViewModels . LXLFuncParams ) )
351+ var tag = me . Tag ;
352+ var tagType = tag . GetType ( ) ;
353+ if ( tagType == typeof ( ViewModels . LXLFuncParams ) )
352354 {
353- var text = ( ( ViewModels . LXLFuncParams ) me . Tag ) . ParamType ;
355+ var t = ( ViewModels . LXLFuncParams ) tag ;
356+ var text = t . ParamType ;
354357 var result = EditFunction ( text ) ;
355- ( ( ViewModels . LXLFuncParams ) me . Tag ) . ParamType = result ;
358+ t . ParamType = result ;
356359 }
357- else if ( me . GetType ( ) == typeof ( ViewModels . LXLFunction ) )
360+ else if ( tagType == typeof ( ViewModels . LXLFunction ) )
358361 {
359- var text = ( ( ViewModels . LXLFunction ) me . Tag ) . ReturnType ;
362+ var t = ( ViewModels . LXLFunction ) tag ;
363+ var text = t . ReturnType ;
360364 var result = EditFunction ( text ) ;
361- ( ( ViewModels . LXLFunction ) me . Tag ) . ReturnType = result ;
362- } else if ( me . GetType ( ) == typeof ( ViewModels . LXLProperty ) )
365+ t . ReturnType = result ;
366+ }
367+ else if ( tagType == typeof ( ViewModels . LXLProperty ) )
363368 {
364- var text = ( ( ViewModels . LXLProperty ) me . Tag ) . PropertyType ;
369+ var t = ( ViewModels . LXLProperty ) tag ;
370+ var text = t . PropertyType ;
365371 var result = EditFunction ( text ) ;
366- ( ( ViewModels . LXLProperty ) me . Tag ) . PropertyType = result ;
372+ t . PropertyType = result ;
367373 }
368374 }
369375 private void SelectTypeComboBox_SelectionChanged ( object sender , SelectionChangedEventArgs e )
@@ -372,7 +378,7 @@ private void SelectTypeComboBox_SelectionChanged(object sender, SelectionChanged
372378 if ( me . SelectedItem ? . ToString ( ) == "Function" )
373379 {
374380 //e.Handled = true;
375- var result = EditFunction ( me . Text ) ; //还未更新的Text
381+ var result = EditFunction ( me . Text ) ; //还未因选择而更改的Text
376382 Dispatcher . InvokeAsync ( ( ) => me . Text = result ) ; //奇怪的bug,事件内直接改没效果,所以只能post到事件完成后运行
377383 }
378384 }
0 commit comments