在WPF中为边框控制设置自定义工具提示

时间:2017-11-03 07:26:57

标签: c# wpf xaml internationalization

我正致力于将WPF应用程序国际化。我陷入了这样一种情况,即在边界控件附近设置一个ToolTip,它将被连接起来:

RoleType : Manager

我在ViewModel中绑定了RoleType,它有Manager,TechLead,Engineer等.RoleType字符串是固定的,在Resources文件中翻译。现在,我需要连接并显示已登录的用户。

我尝试了MultiBinding,但登录后,我的屏幕变黑了。我无法退出我的申请。

以下是我正在尝试的代码:

<StackPanel Grid.Row="0" Orientation="Vertical" VerticalAlignment="Top">
    <Border BorderBrush="{Binding BorderBrush}"  HorizontalAlignment="Center" VerticalAlignment="Center" Height="auto" Width="auto" 
             Background="Transparent" >
        <Border.ToolTip>
            <TextBlock>
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} : {1}">
                        <Binding Path="Text" ElementName="{languageTranslation:Translate RoleType}" />
                        <Binding Path="Text" ElementName="{languageTranslation:Translate {Binding UserName}}" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </Border.ToolTip>
        <ContentControl Height="65" VerticalContentAlignment="Top" HorizontalAlignment="Center" ContentTemplate="{StaticResource UserProfileIcon}"></ContentControl>
    </Border>

我做错了什么?转换器不是必需的,因为它只是字符串。

0 个答案:

没有答案
相关问题