Question

I have a TabControl that has this TabItem in XAML.

<controls:TabItem x:Name="UserNameOn1" Background="LightGray" Height="25"  Visibility="Visible"  IsSelected="False" MouseLeftButtonDown="teste110_MouseLeftButtonDown">
      <controls:TabItem.Header>
           <StackPanel x:Name="TabitemPanel" Orientation="Horizontal" VerticalAlignment="Center">
                   <Image x:Name="UserImage" Source="/Tese;component/Images/user_act.png" Width="30" Height="15" Margin="0,0,0,0" VerticalAlignment="Center" ImageFailed="UserImage_ImageFailed"/>
                   <TextBlock Name="Userdisplay"  Text="UserName" Margin="30,0,0,0" VerticalAlignment="Center"/>
           </StackPanel>
      </controls:TabItem.Header>

and in C# I Want to change the Userdisplay Text to conta.Username_v as below, the problem is that by doing this my image inside the TabItem disappears how to make change only the TextBlock and maintain the image

UserNameOn1.Header = conta.Username_v; 
Was it helpful?

Solution

try this

at event or form load whenever you want.

Userdisplay.text = conta.Username_v;

this will chage only the textbox's text only and not effect other

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top