ButtonEdit

De Banane Atomic
Aller à la navigationAller à la recherche

Click

Xaml.svg
<dxe:ButtonEdit ToolTip="Mon ToolTip"
                DefaultButtonClick="ButtonEdit_DefaultButtonClick">
    <dxe:ButtonEdit.EditValue>
        <Binding Path="MaPropriété" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
            <Binding.ValidationRules>
                <ExceptionValidationRule />
            </Binding.ValidationRules>
        </Binding>
    </dxe:ButtonEdit.EditValue>
</dxe:ButtonEdit>

Command

Xaml.svg
<dxe:ButtonEdit ToolTip="Mon ToolTip"
                AllowDefaultButton="False">
    <dxe:ButtonEdit.EditValue>
        <Binding Path="MaPropriété" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
            <Binding.ValidationRules>
                <ExceptionValidationRule />
            </Binding.ValidationRules>
        </Binding>
    </dxe:ButtonEdit.EditValue>
    <dxe:ButtonInfo ClickMode="Release" GlyphKind="Regular"
                    Command="{Binding Path=MaCommande}"/>
</dxe:ButtonEdit>

Modifier le texte seulement via le bouton

Xaml.svg
<dxe:ButtonEdit IsTextEditable="False">
</dxe:ButtonEdit>

Avec OpenFileDialog

Xaml.svg
<dxe:ButtonEdit DefaultButtonClick="ButtonEdit_DefaultButtonClick" 
                IsTextEditable="False"
                Text="{Binding Path=FilePath}" />
Csharp.svg
private void ButtonEdit_DefaultButtonClick(object sender, RoutedEventArgs e)
{
    var buttonEdit = sender as ButtonEdit;

    var ofd = new OpenFileDialog()
    {
        RestoreDirectory = true,
        Filter = "Fichiers XML|*.xml;*.xaml|All Files|*.*"
    };

    if (ofd.ShowDialog(this) == true && File.Exists(ofd.FileName))
    {
        buttonEdit.EditValue = ofd.FileName;
    }
}