English 中文(简体)
我怎么能够把多个财产约束在相同的世界森林基金控制上?
原标题:How can I bind multiple properties on the same WPF control?

我能够把我的数据来源与显示案文的正文联系起来。 然而,如果检查箱foo<>/strong>的价值得到核实,我就把“Fontlin”设定为黑体。 我试图利用<IMultiValueConverter<>来做到这一点,但迄今没有幸运。 任何关于我做什么错误的想法?

<CheckBox Name="foo"/>
<TextBlock Name="bar" Text="{Binding Path=Name}">
    <TextBlock.FontWeight>
        <MultiBinding Converter="{StaticResource FontConverter}">
            <Binding RelativeSource="{RelativeSource self}" Path="???"/>
            <Binding ElementName="???" />
        </MultiBinding>
    </TextBlock.FontWeight>
</TextBlock>

以及兑换商班(现在总是以黑体返回的硬通布)

Public Class FontConverter
    Implements IMultiValueConverter

    Public Function Convert(values() As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IMultiValueConverter.Convert
        Return "Bold"
    End Function

    Public Function ConvertBack(value As Object, targetTypes() As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object() Implements System.Windows.Data.IMultiValueConverter.ConvertBack
        Return nothing
    End Function
End Class
最佳回答

如果你想要使用转换器,那么你应当对<代码>具有约束力。 查询Box.Isecked ({Bled IsChecked, ElementName=foo>, 之后在上,在Convert上,将 > 至>>>上,根据该编码,将正常或粗体(最好作为实际编码>/code>,而不是一个编码<<<>>>。

Here however i would recommend a DataTrigger on IsChecked.

e.g.

<TextBlock Text="{Binding Name}">
    <TextBlock.Style>
        <Style TargetType="TextBlock">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsChecked, ElementName=foo}"
                             Value="true">
                    <Setter Property="FontWeight" Value="Bold"/>
                </DataTrigger >
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>

(Also note dependency property pre,如果你在当地确定FonWala,触发器将没有任何东西的话)

问题回答

根据XAML的一项条件进行的任何计算,都应在<条码>上填写。 <代码>在将数值从一个数值转换为另一个数值时,应当使用

例如:

<CheckBox Name="foo"/>
<TextBlock Name="bar" Text="{Binding Path=Name}">
    <TextBlock.Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="FontWeight" Value="Normal" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=foo, Path=IsChecked}" Value="True">
                    <Setter Property="FontWeight" Value="Bold" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...