Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic wpf master detail customization (Read 1204 times)
David Chiang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 47
Joined: Apr 15th, 2020
wpf master detail customization
Jun 25th, 2020 at 2:29am
Print Post  
Hello, Try to customization some label's attributes. It works for the master area but not for the detail parts.


<!-- Order info -->
<r:Label Location="0%,24" Size="100%,8" Background="DarkBlue" />
<r:Label Location="{Binding headloc0}" Size="{Binding datasize0}" Visibility="{Binding labshow0}" HorizontalAlignment="{Binding headhorz0}" Text="{Binding h0}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding headloc1}" Size="{Binding datasize1}" Visibility="{Binding labshow1}" HorizontalAlignment="{Binding headhorz1}" Text="{Binding h1}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding headloc2}" Size="{Binding datasize2}" Visibility="{Binding labshow2}" HorizontalAlignment="{Binding headhorz2}" Text="{Binding h2}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding headloc3}" Size="{Binding datasize3}" Visibility="{Binding labshow3}" HorizontalAlignment="{Binding headhorz3}" Text="{Binding h3}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding headloc4}" Size="{Binding datasize4}" Visibility="{Binding labshow4}" HorizontalAlignment="{Binding headhorz4}" Text="{Binding h4}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding headloc5}" Size="{Binding datasize5}" Visibility="{Binding labshow5}" HorizontalAlignment="{Binding headhorz5}" Text="{Binding h5}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding headloc6}" Size="{Binding datasize6}" Visibility="{Binding labshow6}" HorizontalAlignment="{Binding headhorz6}" Text="{Binding h6}" Style="{StaticResource HeaderLabelStyle}" />
<r:Label Location="{Binding dataloc0}" Size="{Binding datasize0}" Visibility="{Binding labshow0}" HorizontalAlignment="{Binding datahorz0}" Text="{Binding col0}" Style="{StaticResource ContentLabelStyle}" />
<r:Label Location="{Binding dataloc1}" Size="{Binding datasize1}" Visibility="{Binding labshow1}" HorizontalAlignment="{Binding datahorz1}" Text="{Binding col1}" Style="{StaticResource ContentLabelStyle}" />
<r:Label Location="{Binding dataloc2}" Size="{Binding datasize2}" Visibility="{Binding labshow2}" HorizontalAlignment="{Binding datahorz2}" Text="{Binding col2}" Style="{StaticResource ContentLabelStyle}" />
<r:Label Location="{Binding dataloc3}" Size="{Binding datasize3}" Visibility="{Binding labshow3}" HorizontalAlignment="{Binding datahorz3}" Text="{Binding col3}" Style="{StaticResource ContentLabelStyle}" />
<r:Label Location="{Binding dataloc4}" Size="{Binding datasize4}" Visibility="{Binding labshow4}" HorizontalAlignment="{Binding datahorz4}" Text="{Binding col4}" Style="{StaticResource ContentLabelStyle}" />
<r:Label Location="{Binding dataloc5}" Size="{Binding datasize5}" Visibility="{Binding labshow5}" HorizontalAlignment="{Binding datahorz5}" Text="{Binding col5}" Style="{StaticResource ContentLabelStyle}" />
<r:Label Location="{Binding dataloc6}" Size="{Binding datasize6}" Visibility="{Binding labshow6}" HorizontalAlignment="{Binding datahorz6}" Text="{Binding col6}" Style="{StaticResource ContentLabelStyle}" />


This part is the master area and it works OK. I try to use same way to apply for the detail but it only work for visibility.

<r:DataRange Location="0%,50" Size="100%,7" Name="Rpt">

<r:DataRange.HeaderTemplate>
<DataTemplate>
<r:ItemContainer Size="100%,8" Background="DarkBlue">
<r:Label Location="0%,1" Size="{Binding datasize0}" Text="{Binding h0}" Visibility="{Binding labshow0}" Style="{StaticResource HeaderLabelStyle2}" />
<r:Label Location="12%,1" Size="{Binding datasize1}" Text="{Binding h1}" Visibility="{Binding labshow1}" Style="{StaticResource HeaderLabelStyle2}" />
<r:Label Location="40%,1" Size="{Binding datasize2}" Text="{Binding h2}" Visibility="{Binding labshow2}" Style="{StaticResource HeaderLabelStyle2}" />
<r:Label Location="54%,1" Size="{Binding datasize3}" Text="{Binding h3}" Visibility="{Binding labshow3}" Style="{StaticResource HeaderLabelStyle2}" />
<r:Label Location="68%,1" Size="{Binding datasize4}" Text="{Binding h4}" Visibility="{Binding labshow4}" Style="{StaticResource HeaderLabelStyle2}" />
<r:Label Location="80%,1" Size="{Binding datasize5}" Text="{Binding h5}" Visibility="{Binding labshow5}" Style="{StaticResource HeaderLabelStyle2}" />
</r:ItemContainer>
</DataTemplate>
</r:DataRange.HeaderTemplate>

<r:DataRange.ItemTemplate>
<DataTemplate>
<r:ItemContainer>
<r:Label Location="0%,0" Size="{Binding datasize0}" Text="[col0]" Visibility="{Binding labshow0}" Style="{StaticResource ContentLabelStyle2}" />
<r:Label Location="12%,0" Size="{Binding datasize1}" Text="[col1]" Visibility="{Binding labshow1}" Style="{StaticResource ContentLabelStyle2}" />
<r:Label Location="40%,0" Size="{Binding datasize2}" Text="[col2]" Visibility="{Binding labshow2}" Style="{StaticResource ContentLabelStyle2}" />
<r:Label Location="54%,0" Size="{Binding datasize3}" Text="[col3]" Visibility="{Binding labshow3}" TextFormat="${0:0.00}" Style="{StaticResource ContentLabelStyle2}" />
<r:Label Location="68%,0" Size="{Binding datasize4}" Text="[col4]" Visibility="{Binding labshow4}" TextFormat=" {0}%" Style="{StaticResource ContentLabelStyle2}" />
<r:Label Location="80%,0" Size="{Binding datasize5}" Visibility="{Binding labshow5}" Background="#EFEFFF" />
<r:Label Location="80%,0" Size="{Binding datasize5}" Text="[col5]" Visibility="{Binding labshow5}" TextFormat="${0:0.00}" Style="{StaticResource ContentLabelStyle2}" />

</r:ItemContainer>
</DataTemplate>
</r:DataRange.ItemTemplate>


Thanks

David Chiang

ps. using sample project "invoice"
  

2020-06-25_102906.png ( 20 KB | 18 Downloads )
2020-06-25_102906.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: wpf master detail customization
Reply #1 - Jun 25th, 2020 at 2:29pm
Print Post  
Hi,

What's not working exactly? I've edited the ContentLabelStyle2 style used by details' labels and it seems to work well enough.

Code
Select All
<Style TargetType="{x:Type r:Label}" x:Key="ContentLabelStyle2">
    <Setter Property="Foreground" Value="LightBlue" />
	<Setter Property="HorizontalAlignment" Value="Left" />
	<Setter Property="VerticalAlignment" Value="Center" />
	<Setter Property="BorderBrush" Value="DarkBlue" />
	<Setter Property="BorderThickness" Value="0,0,0,1" />
	<Setter Property="Padding" Value="0,0,5,0" />
</Style> 



If you mean Binding expressions are not working, that would happen if there are no such properties / columns in the detail objects. Detail objects are set as data contexts for each templated item in the range, and bindings by simple name will work only if that name is available in the detail context.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
David Chiang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 47
Joined: Apr 15th, 2020
Re: wpf master detail customization
Reply #2 - Jun 26th, 2020 at 6:17am
Print Post  
I am not using style setting but use my own parameters. Here is the code I am using.

                            <!-- Order details -->
                            <r:DataRange Location="0%,50" Size="100%,7" Name="Rpt">

                                <r:DataRange.HeaderTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer Size="100%,8" >
                                            <r:Label Location="{Binding headloc0}" Size="{Binding datasize0}" Text="{Binding h0}" Visibility="{Binding labshow0}"  />
                                            <r:Label Location="{Binding headloc1}" Size="{Binding datasize1}" Text="{Binding h1}" Visibility="{Binding labshow1}"  />
                                            <r:Label Location="{Binding headloc2}" Size="{Binding datasize2}" Text="{Binding h2}" Visibility="{Binding labshow2}" />
                                            <r:Label Location="{Binding headloc3}" Size="{Binding datasize3}" Text="{Binding h3}" Visibility="{Binding labshow3}" />
                                            <!--<r:Label Location="68%,1" Size="{Binding datasize4}" Text="{Binding h4}" Visibility="{Binding labshow4}" />
                                            <r:Label Location="80%,1" Size="{Binding datasize5}" Text="{Binding h5}" Visibility="{Binding labshow5}" />-->
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.HeaderTemplate>

                                <r:DataRange.ItemTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer>
                                            <r:Label Location="{Binding dataloc0}" Size="{Binding datasize0}" Text="[col0]" Visibility="{Binding labshow0}" />
                                            <r:Label Location="{Binding dataloc1}" Size="{Binding datasize1}" Text="[col1]" Visibility="{Binding labshow1}" />
                                            <r:Label Location="{Binding dataloc2}" Size="{Binding datasize2}" Text="[col2]" Visibility="{Binding labshow2}"  />
                                            <r:Label Location="{Binding dataloc3}" Size="{Binding datasize3}" Text="[col3]" Visibility="{Binding labshow3}"  TextFormat="${0:0.00}"/>
                                            <!--<r:Label Location="68%,0" Size="{Binding datasize4}" Text="[col4]" Visibility="{Binding labshow4}"  TextFormat=" {0}%"/>
                                            <r:Label Location="80%,0" Size="{Binding datasize5}" Visibility="{Binding labshow5}" Background="#EFEFFF" />
                                            <r:Label Location="80%,0" Size="{Binding datasize5}" Text="[col5]" Visibility="{Binding labshow5}"  TextFormat="${0:0.00}" Style="{StaticResource ContentLabelStyle2}" />-->
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.ItemTemplate>


Here is the binding data.


LineRecCount : 3
Next Record
headlab0 = 商品編號
headloc0 = 0%,1
dataloc0 = 0%,0
datasize0 =
headhorz0 = Left
datahorz0 = Right
labshow0 = Visible
Next Record
headlab1 = 商品價
headloc1 = 12%,1
dataloc1 = 12%,0
datasize1 =
headhorz1 = Left
datahorz1 = Right
labshow1 = Visible
Next Record
headlab2 = 數量
headloc2 = 40%,1
dataloc2 = 40%,0
datasize2 =
headhorz2 = Left
datahorz2 = Right
labshow2 = Visible
Next Record
headlab3 = PV
headloc3 = 54%,1
dataloc3 = 54%,0
datasize3 =
headhorz3 = Left
datahorz3 = Right
labshow3 = Visible
Next Record
headlab4 =
headloc4 =
dataloc4 =
datasize4 =
headhorz4 =
datahorz4 =
labshow4 = Hidden
Next Record
headlab0 = 商品編號
headloc0 = 0%,1
dataloc0 = 0%,0
datasize0 =
headhorz0 = Left
datahorz0 = Right
labshow0 = Visible
Next Record
headlab1 = 商品價
headloc1 = 12%,1
dataloc1 = 12%,0
datasize1 =
headhorz1 = Left
datahorz1 = Right
labshow1 = Visible
Next Record
headlab2 = 數量
headloc2 = 40%,1
dataloc2 = 40%,0
datasize2 =
headhorz2 = Left
datahorz2 = Right
labshow2 = Visible
Next Record
headlab3 = PV
headloc3 = 54%,1
dataloc3 = 54%,0
datasize3 =
headhorz3 = Left
datahorz3 = Right
labshow3 = Visible
Next Record
headlab4 =
headloc4 =
dataloc4 =
datasize4 =
headhorz4 =
datahorz4 =
labshow4 = Hidden
Next Record
headlab0 = 商品編號
headloc0 = 0%,1
dataloc0 = 0%,0
datasize0 =
headhorz0 = Left
datahorz0 = Right
labshow0 = Visible
Next Record
headlab1 = 商品價
headloc1 = 12%,1
dataloc1 = 12%,0
datasize1 =
headhorz1 = Left
datahorz1 = Right
labshow1 = Visible
Next Record
headlab2 = 數量
headloc2 = 40%,1
dataloc2 = 40%,0
datasize2 =
headhorz2 = Left
datahorz2 = Right
labshow2 = Visible
Next Record
headlab3 = PV
headloc3 = 54%,1
dataloc3 = 54%,0
datasize3 =
headhorz3 = Left
datahorz3 = Right
labshow3 = Visible

the picture is the result. I use the ways to head session and it works fine. Anything I need to do?

Thanks

David Chiang
  

2020-06-26_141502.png ( 21 KB | 15 Downloads )
2020-06-26_141502.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: wpf master detail customization
Reply #3 - Jun 26th, 2020 at 9:17am
Print Post  
Do you store those datalocN and datasizeN values in detail objects though? Each detail row is set as data context of data-range item's template, and so that's where binding expressions by a simple name will look for them. Other than that, verify properties are of same type as ReportItem's (Location and Dimension class from reporting namespace), or otherwise you must also add a value converter to the binding.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
David Chiang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 47
Joined: Apr 15th, 2020
Re: wpf master detail customization
Reply #4 - Jun 26th, 2020 at 10:36am
Print Post  
I use same method as I use in order info

                            <r:Label Location="{Binding headloc0}" Size="{Binding datasize0}" Visibility="{Binding labshow0}" HorizontalAlignment="{Binding headhorz0}" Text="{Binding h0}" />
                            <r:Label Location="{Binding headloc1}" Size="{Binding datasize1}" Visibility="{Binding labshow1}" HorizontalAlignment="{Binding headhorz1}" Text="{Binding h1}"/>
                            <r:Label Location="{Binding headloc2}" Size="{Binding datasize2}" Visibility="{Binding labshow2}" HorizontalAlignment="{Binding headhorz2}" Text="{Binding h2}" />
                            <r:Label Location="{Binding headloc3}" Size="{Binding datasize3}" Visibility="{Binding labshow3}" HorizontalAlignment="{Binding headhorz3}" Text="{Binding h3}"  />
                            <r:Label Location="{Binding headloc4}" Size="{Binding datasize4}" Visibility="{Binding labshow4}" HorizontalAlignment="{Binding headhorz4}" Text="{Binding h4}"  />
                            <r:Label Location="{Binding headloc5}" Size="{Binding datasize5}" Visibility="{Binding labshow5}" HorizontalAlignment="{Binding headhorz5}" Text="{Binding h5}" />
                            <r:Label Location="{Binding headloc6}" Size="{Binding datasize6}" Visibility="{Binding labshow6}" HorizontalAlignment="{Binding headhorz6}" Text="{Binding h6}" />
                            <r:Label Location="{Binding dataloc0}" Size="{Binding datasize0}" Visibility="{Binding labshow0}" HorizontalAlignment="{Binding datahorz0}" Text="{Binding col0}" />
                            <r:Label Location="{Binding dataloc1}" Size="{Binding datasize1}" Visibility="{Binding labshow1}" HorizontalAlignment="{Binding datahorz1}" Text="{Binding col1}" />
                            <r:Label Location="{Binding dataloc2}" Size="{Binding datasize2}" Visibility="{Binding labshow2}" HorizontalAlignment="{Binding datahorz2}" Text="{Binding col2}" />
                            <r:Label Location="{Binding dataloc3}" Size="{Binding datasize3}" Visibility="{Binding labshow3}" HorizontalAlignment="{Binding datahorz3}" Text="{Binding col3}" />
                            <r:Label Location="{Binding dataloc4}" Size="{Binding datasize4}" Visibility="{Binding labshow4}" HorizontalAlignment="{Binding datahorz4}" Text="{Binding col4}"/>
                            <r:Label Location="{Binding dataloc5}" Size="{Binding datasize5}" Visibility="{Binding labshow5}" HorizontalAlignment="{Binding datahorz5}" Text="{Binding col5}"/>
                            <r:Label Location="{Binding dataloc6}" Size="{Binding datasize6}" Visibility="{Binding labshow6}" HorizontalAlignment="{Binding datahorz6}" Text="{Binding col6}" />


and it worked

data as following

Head Data
OrderID   0%,25   0%,32   14%,6   Center   Center   Visible
Head Data
DSID   14%,25   14%,32   14%,6   Left   Right   Visible
Head Data
倉儲   28%,25   28%,32   14%,6   Left   Center   Visible
Head Data
訂單日期   42%,25   42%,32   14%,6   Left   Right   Visible
Head Data
Total Sales   56%,25   56%,32   50%,6   Left   Right   Visible

Are there any different ways to apply?

Regards
  

2020-06-26_183637.png ( 8 KB | 17 Downloads )
2020-06-26_183637.png
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: wpf master detail customization
Reply #5 - Jun 26th, 2020 at 2:26pm
Print Post  
Data context for headers is the master table, so header bindings will work if the properties you bind to are in the master table / objects. Data context for details is set to respective detail rows, so bindings there will work for properties in the details table / objects. If your dataloc/datasize properties are in same table/object as headerloc/headersize, details binding probably fails (doesn't it show some System.Windows.Data Error messages in VS console?). So if you need location and size bound to data objects, try moving the dataloc/datasize properties from master to detail ones.

If you are doing all this in order to change column size dynamically, maybe you could create col1style, col2style etc Style objects and assign them to the Style property of respective column's labels, and later change the style setter value from code.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
David Chiang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 47
Joined: Apr 15th, 2020
Re: wpf master detail customization
Reply #6 - Jun 27th, 2020 at 3:59am
Print Post  
OK, Thanks I will try that approach.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint