English 中文(简体)
检查后未更新的检查状况 方框模板
原标题:Checked status not updated in CheckBox template

我试图建立一个超文本链接,根据干.的价值改变其案文。 我认为,我可以利用CayBox的方法。 因此,我撰写了该《控制图》,以备查Box:

 <CheckBox Checked="CheckBox_Checked" IsChecked="{Binding Path=SomeBool, Mode=TwoWay}">
     <CheckBox.Template>
         <ControlTemplate TargetType="{x:Type CheckBox}">
             <BulletDecorator>
                <BulletDecorator.Bullet>
                    <TextBlock>
                        <Hyperlink>
                        <TextBlock x:Name="TextBoxHyperlink">Unchecked</TextBlock>
                        </Hyperlink>
                    </TextBlock>
                </BulletDecorator.Bullet>
                <ContentPresenter />
                </BulletDecorator>
                <ControlTemplate.Triggers>
                   <Trigger Property="IsChecked" Value="True">
                       <Setter TargetName="TextBoxHyperlink" 
                               Property="Text" 
                               Value="Checked" />
                   </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
        </CheckBox.Template>
    </CheckBox>

但是,当我点击超链接时,没有发生。 核对状况没有改变,文本Block的文本财产没有更新。 任何想法?

最佳回答

通过在文本Block要素中增加案文内容,你重新确定了文本财产的地方价值。 当地价值观超越了触发因素设定的价值观,因此,你的触发点不会产生影响。 See this StackOverflow question or

如果你确定文本财产,而不是增加内容,将被视为母体模板财产,并低于母体模板触发因素:

<TextBlock x:Name="TextBoxHyperlink" Text="Unchecked"/>

而且,它像你一样,只使用一种Box,因为你想要一个基于蓝.财产的触发点。 您可使用DataTrigger,而不是一个Trigger,对你数据内容上的财产而不是你控制的财产进行约束,或者你只能将文本财产直接与Bool公司挂钩,并使用将真实和虚假转化为“Checked”和“Unchecked”。

问题回答

暂无回答




相关问题
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. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签