DataTemplate for Custom Control with ContentPresenter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?V29ua28gdGhlIFNhbmU=?=

    #1

    DataTemplate for Custom Control with ContentPresenter

    Hello,

    I am using a custom control (based on Button), which has in its generic
    implementation:

    <Setter Property="Templ ate">
    <Setter.Value >
    <ControlTemplat e TargetType="loc al:BasedOnButto n">
    |
    |
    <ContentPresent er .... />
    </ControlTemplate >
    </Setter.Value>
    </Setter Property="Templ ate">

    Now, when using this control, I have run into a situation where I want to
    use a DataTrigger (to start an animation when a bound value reaches a certain
    level). However, I cannot get a DataTemplate to show the data I need in that
    control. I'd like something like the following:

    <cust:BasedOnBu tton>
    <cust:BasedOnBu tton.ContentTem plate>
    <DataTemplate >
    <TextBlock Text="{Binding Path=SomePath}" >
    <TextBlock.Trig gers>
    <DataTrigger
    Binding="{Bindi ng
    RelativeSource= {RelativeSource Seld}, Path=AnotherPat h}"
    Value="true">
    |
    |
    </DataTrigger>
    </TextBlock.Trigg ers>
    </TextBlock>
    </DataTemplate>
    </cust:BasedOnBut ton.ContentTemp late>
    </cust:BasedOnBut ton>

    However, when I try to use a DataTemplate, the content of the button just
    shows "Windows.System .DataTemplate"( or something like that), or nothing
    (blank), depending on things I've tried.

    I hope I have explained this enough....

    Thanks,
    WtS



  • Linda Liu

    #2
    Re: DataTemplate for Custom Control with ContentPresente r

    Hi Wonko,

    I want to notify you that there's something wrong with my user account so
    that I couldn't receive any email sent to my company email box these two
    days.

    If you have sent me a sample project that could demonstrate your problem to
    my company email box, please send it to my another email address
    liuting_lliu@ho tmail.com again.

    Thank you and I look forward to your reply!

    Sincerely,
    Linda Liu
    Microsoft Online Community Support


    Comment

    Working...