Dha*_*tel 3 c# wpf binding busyindicator
我在wpf中有一些代码,因为我已经使用了busyindicator并且我设置了datatemplete现在我的问题是我在我的应用程序中使用了mvvm模式而我想使用busyindicator但我不知道如何在busyindicaor datatemplete中绑定textblock.我的代码看起来像
<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>
Run Code Online (Sandbox Code Playgroud)
kma*_*zek 10
您可以使用Binding with RelativeSource.
在ViewModel中添加以下属性:
private string _busyText;
public string BusyText
{
get { return _busyText; }
set { _busyText = value; RaisePropertyChanged(() => BusyText); }
}
Run Code Online (Sandbox Code Playgroud)
并改变这一行:
<TextBlock Text="Downloading message 4/10..."/>
Run Code Online (Sandbox Code Playgroud)
在这一个:
<TextBlock Text="{Binding Path=DataContext.BusyText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1841 次 |
| 最近记录: |