gpt4 book ai didi

c# - 将数据绑定(bind)到 busyindicator 中的数据模板的问题

转载 作者:行者123 更新时间:2023-11-30 13:39:16 25 4
gpt4 key购买 nike

我在 wpf 中有一些代码,因为我使用了 busyindicator 并且我现在设置了 datatemplete 我的问题是我在我的应用程序中使用了 mvvm 模式并且我想在上面使用 busyindicator 但我不知道如何在里面绑定(bind)文本 block busyindicaor datatemplete.my 代码看起来像

<extended:BusyIndicator Name="_busyIndicator">
<extended:BusyIndicator.BusyContentTemplate>
<DataTemplate>
<StackPanel Margin="4">
<TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center" Name="Dhaval"/>
<StackPanel Margin="4">
<TextBlock Text="Downloading message 4/10..."/>
<ProgressBar Value="40" Height="15" x:Name="Progress_Dhaval"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</extended:BusyIndicator.BusyContentTemplate>

最佳答案

您可以将 Binding 与 RelativeSource 结合使用。

在您的 ViewModel 中添加此属性:

        private string _busyText;
public string BusyText
{
get { return _busyText; }
set { _busyText = value; RaisePropertyChanged(() => BusyText); }
}

并更改这一行:

<TextBlock Text="Downloading message 4/10..."/>

关于这个:

<TextBlock Text="{Binding Path=DataContext.BusyText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />

关于c# - 将数据绑定(bind)到 busyindicator 中的数据模板的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12515710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com