Toute idée où je vais mal avec ce code. Je veux que la zone de texte soit activée lorsque le bouton Radio associé pour elle est sélectionné, puis lorsqu'un bouton radio différent est sélectionné, je veux qu'il soit activé = faux. J'ai créé une propriété de dépendance ProxyMode et ai changé le getter pour obtenir sa valeur bool selon si Proxy est sélectionné ou non. Ça ne semble pas fonctionner ... des idées?Essayer d'obtenir IsEnabled pour lier à la propriété de dépendance
// Proxy Host Name
public string Proxy
{
get { return (string)GetValue(ProxyProperty); }
set { SetValue(ProxyProperty, value); }
}
public static readonly DependencyProperty ProxyProperty =
DependencyProperty.Register("Proxy", typeof(string), typeof(ConfigWindowViewModel), new UIPropertyMetadata("[e.g. proxy.mycompany.com]"));
public bool ProxyMode
{
get { return Proxy == "Proxy"; }
set { SetValue(ProxyModeProperty, value); }
}
public static readonly DependencyProperty ProxyModeProperty =
DependencyProperty.Register("ProxyMode", typeof(bool), typeof(ConfigWindowViewModel));
Et le XAML
<StackPanel Grid.Column="0" Margin="2">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<RadioButton IsChecked="{Binding Path=Mode, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Proxy}"
VerticalAlignment="Center"
Padding="2,0,10,0">Proxy
</RadioButton>
<TextBox Text="{Binding Path=Proxy}"
IsEnabled="{Binding Path=ProxyMode}"
Width="Auto"
Name="ProxyHostTextBox"
VerticalAlignment="Center"
MinWidth="150"
/>
</StackPanel>
<RadioButton IsChecked="{Binding Path=Mode, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Direct}">Direct</RadioButton>
</StackPanel>
Vous avez posté cette secondes après ma réponse, mais oui, la même chose essentiellement que ce que j'ai répondu. – Kelsie