我有一个TabControl,在XAML中有这个TabItem。
<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>
在C#中我想将Userdisplay Text更改为conta.Username_v,如下所示,问题是通过这样做我的TabItem内的图像消失了如何只更改TextBlock并保持图像
UserNameOn1.Header = conta.Username_v;
答案 0 :(得分:0)
试试这个
at event or form load whenever you want.
Userdisplay.text = conta.Username_v;
这将仅更改文本框的文本而不会影响其他