So, it's been a long day figuring out the best way to implement a property binding. By the end of it, I threw a hail mary and won!... but I don't know why. Being a fundamentalist, I'd like to know why this line worked:
FormatString="{Binding ElementName=comboRingBuffer, Path=Tag.Format}"
in the following code-behind:
// Argument is a struct with a Limit "property"
private Argument ringBuffer;
public Limit RingBufferPrefix
{
get
{
return this.ringBuffer.Limit;
}
set
{
this.ringBuffer.Limit = value;
this.OnPropertyChanged(nameof(this.RingBufferPrefix));
}
}
public class Limit
{
public Limit(string prefix, string format)
{
this.Prefix = prefix;
this.Format = format;
}
public string Prefix { get; set; }
public string Format { get; set; }
public override string ToString()
{
return this.Prefix;
}
}
and XAML:
<ComboBox x:Name="comboRingBuffer"
SelectionChanged="SelectionChanged_Event"
Tag="{Binding Path=RingBufferPrefix}" />
<xctk:IntegerUpDown x:Name="integerRingBuffer"
DockPanel.Dock="Right"
Style="{StaticResource DigitalInteger}"
ValueChanged="ValueChanged_Event"
FormatString="{Binding ElementName=comboRingBuffer, Path=Tag.Format}"
Value="{Binding Path=RingBuffer}" />
I thought for sure the it would just say that the Tag
is an object
and display nothing.