Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
475
Adding watermark background text to a CellValuePresenter in a XamDataGrid
posted

Hi,

I hope someone can help me with the following, please see the attached image.


Basically I have a Failure Type field with the different types selected from a combobox in the cell.  Depending on the selected failure type then a different value is required in the Failure Param 1 field.  For example, a failure Type of Exponential requires a MTTF value to be entered into Failure Param 1, whereas Failure Type of Triangular will require a Min.TTF value to be entered into Failure Param 1.

I would like to indicate to the user the required type to enter into Failure Param 1 field by displaying the required type as semi-transparent text in the CellValuePresenter (not the XamTextEditor).  In the attached image you can see the effect I want to achieve.  I did this using the code below.

Unfortunately, using a ControlTemplate means that I lose the standard styles of the CellValuePresenter such as the Active Cell colouring and the Data Validation icon appearing.  Can anyone advise me where I am going wrong here ?

Is it possible to achieve this background effect by styling the CellValuePresenter rather than changing it's template ?

<igDP:Field Name="FailureParam1">
 <igDP:Field.Settings>
  <igDP:FieldSettings EditorStyle="{StaticResource rightAligned}">
   <igDP:FieldSettings.CellValuePresenterStyle>
    <Style TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}">
     <Setter Property="ToolTip" Value="{Binding Path=DataItem.FailureParam1Type}" />
     <Setter Property="Template">
      <Setter.Value>
       <ControlTemplate>
        <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Margin="{TemplateBinding Padding}">
         <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Opacity="0.3" Text="{Binding Path=DataItem.FailureParam1Type}" />
         <ContentPresenter x:Name="PART_EditorSite" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
              Margin="{TemplateBinding Padding}"/>
        </Grid>
       </ControlTemplate>
      </Setter.Value>
     </Setter>
    </Style>
   </igDP:FieldSettings.CellValuePresenterStyle>
  </igDP:FieldSettings>
 </igDP:Field.Settings>
</igDP:Field>

  • 27093
    posted

    Hello,

     

    I have been looking into your issue and can say you are on the right track. The thing you are missing on is that we provide with our product the original templates for most of the visual elements in the DefaultStyles folder. You can get a copy of the CellValuePresenter’s style from (default install path) C:\Program Files (x86)\Infragistics\NetAdvantage 2010.3\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml . All you have to do is paste it in your project and add your transparent TextBlock.

     

    Hope this helps. Please let me know if this solves it or I can assist you further on the matter.

     

    Sincerely,

    Petar Monov

    Developer Support Engineer

    Infragistics Bulgaria

    www.infragistics.com/support