I need to alternate text displayed by a single based on two model properties for about 4 seconds. Specifically, my model as a Price, Bid, and Ask property. i have the following text block bound to Price.
<ControlTemplate x:Key="QuotePrice" >
<TextBlock Style="{StaticResource PriceCellStyle}" Text="{Binding Price}">
</ControlTemplate>
If the model’s Ask property changes, i want to toggle between displaying Price and Ask in the same texblock.
The option i think would work would be to create two textblock, one bound to Price and one bound to Ask and using perhaps a storyboard, alternate the visibility of the two texblocks. However, i would like to avoid using two textblock if possible. Any suggestions on how this can be done?
Using two TextBlock instances will be the simplest, and likely the most elegant solution.
However, you could update the binding at runtime, if you’d prefer to stick to a single TextBlock. Alternatively, you could also bind to a new property (ie:
PriceOrAsk), and change it’s value as needed within your DataContext.