locked
Conditional Styles in Lightswitch RRS feed

  • Question

  • Ok let’s make it simple I have two pieces of data in my entity and I want to format one on screen using the info in the other.

    Picture and Color

    The color indicates a organization of the thing pictured. It in no way directly reflects the picture which is a general picture of a model. but to keep identical models separated they each have a color indicator placed on them in real life. I want to use the style tag in the Client.LSML to define a Border around the picture and the ColorOFBorder=Color.

    The target code for the screen Property "picture" on the client side is...

                        <ContentItem

                          DataType="Microsoft.LightSwitch.Extensions:Image?"

                          Kind="Value"

                          Name="Picture"

                          Placement="Image">

                          <ContentItem.DataSource>

                            <ScreenExpressionTree>

                              <ChainExpression>

                                <MemberExpression

                                  Member="LightSwitchCommonModule:Miniature/Properties[Picture]" />

                              </ChainExpression>

                            </ScreenExpressionTree>

                          </ContentItem.DataSource>

                          <ContentItem.PropertySources>

                            <ControlPropertySource

                              Property="Microsoft.LightSwitch:RootControl/Properties[HorizontalAlignment]">

                              <ScreenExpressionTree>

                                <ConstantExpression

                                  ResultType=":String"

                                  Value="Center" />

                              </ScreenExpressionTree>

                            </ControlPropertySource>

                            <ControlPropertySource

                              Property="Microsoft.LightSwitch:RootControl/Properties[AttachedLabelPosition]">

                              <ScreenExpressionTree>

                                <ConstantExpression

                                  ResultType=":String"

                                  Value="Top" />

                              </ScreenExpressionTree>

                            </ControlPropertySource>

                          </ContentItem.PropertySources>

                        </ContentItem>

    The target code for the screen property "color" on the client side is...

                        <ContentItem

                          DataType=":String?"

                          Kind="Value"

                          Name="PlayerCharacters_SelectedItem_BaseColor">

                          <ContentItem.DataSource>

                            <ScreenExpressionTree>

                              <ChainExpression>

                                <MemberExpression

                                  Member="CampaignDetails/Properties[PlayerCharacters]" />

                                <MemberExpression

                                  Member="SelectedItem" />

                                <MemberExpression

                                  Member="BaseColor" />

                              </ChainExpression>

                            </ScreenExpressionTree>

                          </ContentItem.DataSource>

                        </ContentItem>

                      </ContentItem>

    The sample code for adding style is this were a DataGrid and I just changes the background color of the "Color" Property in the screen after it is listed.

        <DataGrid Name="dataGrid1" Margin="12,12,0,0">
           
    <DataGrid.RowStyle>
               
    <Style TargetType="DataGridRow">
                   
    <Setter Property="Background" Value="{Binding Path=colorCol}" />
               
    </Style>
           
    </DataGrid.RowStyle>
       
    </DataGrid>

    Wednesday, September 18, 2013 9:46 PM

All replies