私はDenis VuykaのWPF用にthis プロパティコントロールを使用しています。WPF PropertyGridはプロパティ値を適用しません
Tabキーを押さないと、プロパティの新しい値が適用されないという問題があります。
プロパティグリッドのプロパティを変更して[OK]ボタンをクリックすると、そのプロパティは以前の値のままです。
サンプル・コードは、再現する:
public partial class MainWindow : Window
{
DataObject dataObject = new DataObject();
public MainWindow()
{
InitializeComponent();
propertyGrid.SelectedObject = dataObject;
}
private void OnOK(object sender, RoutedEventArgs e)
{
MessageBox.Show("Value of test is " + dataObject.test);
}
}
class DataObject
{
public int test { get; set; }
public int test2 { get; set; }
}
<Window x:Class="PropGridTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pg="http://schemas.denisvuyka.wordpress.com/wpfpropertygrid"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0" IsDefault="True" Click="OnOK">OK</Button>
<pg:PropertyGrid x:Name="propertyGrid" Grid.Row="1">
</pg:PropertyGrid>
</Grid>
</Window>
ちょうど性試験に番号を入力し、[OK]ボタンをクリックします。
誰かがこの問題の回避策を知っていますか?
これは私がこれまで無駄にOnOK呼び出しにしようとしたものです:
propertyGrid.Focus();
propertyGrid.MoveFocus(new System.Windows.Input.TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
System.Windows.Forms.SendKeys.SendWait("{TAB}");
これを行うには、ソースコードの正しい場所はどこですか?教えてください。 – MTR
@MTR:それは大きな疑問です。 :)私はあなたが変更を行うための適切な場所を見つけるのに役立つ答えを編集しました。あるいは、著者に変更を加えたり、バグレポートを提出したり、速やかに修正してもらうことができます。 –