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
289
Multiple Style i.e Applying CellValuePresenterStyle and DataRecordPresenterStyle
posted

Hey,

We need little assistance on this one. All our fields/columns are loading various styles depending on the type of data.  All styles are working fine in their individual Cell. Now we have a situation where we would like to set the background color of the entire record based on a field and the individual cell should continue displaying their corresponding style.

Example:

My datagrid contains 4 fields/Columns named Play, Stop, Queue, Name. Correspnding to each field we have specified a CellValuePresenter style which loads images. This is all working. Now based on specific Queue field we need to highlight or set the background color of the entire record. This can't be CellValuePresenter Style as this would overwrite our previous styles for individual cells. DataRecordPresenter style may be the option But couldn't get that one working. We want to do this in xaml and not in code.

How do we deal with such a situation.

Thanks

Ferhaad 

 

 

Parents
  • 310
    posted

    Hi,

    I have to apply different style for a cell based on a condition for e.g. if my data type is image I have to display a button using cellvaluepresenter for browsing, else nothing should be their for that cell. Problem is last style which I assgined on the cell same style gets applied for the entire column.

    If currentRecord.Cells("DisplayType").Value = "Image" Or currentRecord.Cells("DisplayType").Value = "System.Binary" Then

    currentRecord.Cells("ImageFile").Field.Settings.CellValuePresenterStyle = DirectCast(FindResource("ButtonPresenterStyle"), Style)

    OR

    currentRecord.FieldLayout.Fields("ImageFile").Settings.CellValuePresenterStyle = DirectCast(FindResource("ButtonPresenterStyle"), Style)

    Else

    currentRecord.Cells("ImageFile").Field.Settings.CellValuePresenterStyle = DirectCast(FindResource("NoButtonPresenterStyle"), Style)

    OR

    currentRecord.FieldLayout.Fields("ImageFile").Settings.CellValuePresenterStyle = DirectCast(FindResource("NoButtonPresenterStyle"), Style)

    End If

    <Style x:Key="ButtonPresenterStyle"

    TargetType="{x:Type igDP:CellValuePresenter}">

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

    <Canvas>

    <Button x:Name="btnControlButton"

    Margin="2"

    Click="btnControlButton_Click"

    Content="...">

    </Button>

    </Canvas>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

    <Style x:Key="NoButtonPresenterStyle"

    TargetType="{x:Type igDP:CellValuePresenter}">

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

    <Label>NoButton</Label>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

    </Window.Resources>

    Any reason like where I am going wrong or whether it is possible 

    Thanks 

     

Reply Children
No Data