简体   繁体   中英

WPF: {DependencyPropety.UnsetValue} woes

I have a problem with my bindings which I can't fix! Instead of displaying the required value, I get a {DependencyProperty.UnsetValue}.

Here is the XAML :

    <TextBlock Visibility="{Binding DisplayBuyPriceConverted, Converter={StaticResource boolVisibilityConverter}}" Grid.ColumnSpan="2" Grid.Row="4">
            <TextBlock.Text>
                <MultiBinding StringFormat="Converted Price: {0} {1}">
                    <Binding Path="BuyPriceConverted" Mode="OneWay"></Binding>
                    <Binding Path="CharterSellPriceCurrency" Mode="OneWay"></Binding>
                </MultiBinding>
            </TextBlock.Text>
    </TextBlock>

Here is what it used to look like, which works fine:

    <TextBlock Text="{Binding Path=BuyPriceConverted, StringFormat=Converted Price: {0} GBP, Mode=OneWay}" Margin="5,0,0,0" Width="149" Visibility="{Binding DisplayBuyPriceConverted, Converter={StaticResource boolVisibilityConverter}}" DataContext="{Binding}"></TextBlock>

Here is the C# which specifies the DataContext:

    public AdditionalCostDialogue(AdditionalCostView additionalCostView)
    {
        InitializeComponent();
        this._additionalCostView = additionalCostView;
        this.DataContext = this.AdditionalCostView;
    }

What am I doing wrong?

I discovered that one of my properties is a decimal. Sorry about that guys, I lead you on a wild goose chase. All working now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM