ich eine bedingte Textbox Usercontrol zu schaffen versuche, auf dem es eine Eigenschaft, diePassing Wert von gebundenen Ansichtsmodell zu Usercontrol
- Bedingung akzeptiert (true | false, Binding)
- FalseValue (true | false , Bindung, Static)
- Truevalue (true | false, Binden, Static)
Das Problem ist mein Static und Literalwert funktioniert gut bis auf die Bindung.
<Grid Background="#FFBDBDBD" Margin="0,154,0,266">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="33*"></RowDefinition>
<RowDefinition Height="33*"></RowDefinition>
<RowDefinition Height="33*"></RowDefinition>
</Grid.RowDefinitions>
<userControls:ConditionalTextBox
Grid.Column="0"
Grid.Row="0"
Condition="{Binding Path=IsTrue, Mode=TwoWay}"
FalseValue="{StaticResource FalseValRes}"
TrueValue="{StaticResource TrueValRes}"
HorizontalAlignment="Left" Width="500">
</userControls:ConditionalTextBox>
<userControls:ConditionalTextBox
Grid.Column="0"
Grid.Row="1"
Condition="True"
FalseValue="{Binding FalseValueDefined}"
TrueValue="{Binding TrueValueDefined}"
HorizontalAlignment="Left" Width="500">
</userControls:ConditionalTextBox>
<userControls:ConditionalTextBox
Grid.Column="0"
Grid.Row="2"
Condition="False"
FalseValue="False Value (string)"
TrueValue="True Value (string)"
HorizontalAlignment="Left" Width="500">
</userControls:ConditionalTextBox>
</Grid>
mit Code hinter
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.DataContext = new VMTest
{
IsTrue = true,
FalseValueDefined = "False Value (Binding)",
TrueValueDefined = "True Value (Binding)"
};
}
}
und diese VM
public class VMTest : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool isTrue;
public bool IsTrue
{
get { return isTrue; }
set
{
isTrue = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("IsTrue"));
}
}
private string trueValueDefined;
public string TrueValueDefined
{
get { return trueValueDefined; }
set
{
trueValueDefined = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("TrueValueDefined"));
}
}
public string falseValueDefined;
public string FalseValueDefined
{
get { return falseValueDefined; }
set
{
falseValueDefined = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("FalseValueDefined"));
}
}
}
als Ergebnis Static und Literalwert erfolgreich zu Usercontrol erreicht und vielleicht habe ich etwas auf Bindungen, die es beeinflussen würde nicht
Ergebnis
Jede Hilfe würde geschätzt.
TIA
danke für Ihre Antwort. Ich kann PresentationTraceSources nicht finden. PS: das ist Windows Store apps nicht wpf –
Ich nehme es der erste Vorschlag hat nicht funktioniert? Weitere Informationen zur Verwendung von PresentationalTraceSources finden Sie unter http://wpftutorial.net/DebugDataBinding.html, indem Sie den Namespace explizit angeben. – FishySwede