Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problems with binding data to data templates inside a busyindicator

i have some code in wpf in that i have used busyindicator and i set datatemplete now my problem is that i used mvvm pattern in my applicaton and i want to used busyindicator on that but i don't know how to binding textblock inside busyindicaor datatemplete.my code look like

<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>

like image 231
Dhaval Patel Avatar asked Jun 30 '26 07:06

Dhaval Patel


1 Answers

You can use Binding with RelativeSource.

Add in your ViewModel this property:

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

And change this line:

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

on this one:

<TextBlock Text="{Binding Path=DataContext.BusyText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
like image 200
kmatyaszek Avatar answered Jul 03 '26 14:07

kmatyaszek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!