DataTemplate Binding Data Print?
We cannot understand your requirement clearly. We suspect that your reported problem is , the binding is not worked for some properties that is declared inside the DataTemplate . If this is your requirement then you can setting the DataContext like below code example,
Code Example:
|
<Window.Resources> <local:ViewModel x:Key="viewmodel"/> <DataTemplate x:Key="PrintHeader" > <Border BorderThickness="1"> <Grid DataContext="{StaticResource viewmodel}"> <Grid.RowDefinitions> <RowDefinition Height="50"></RowDefinition> <RowDefinition Height="25"></RowDefinition> <RowDefinition Height="25"></RowDefinition> <RowDefinition Height="25"></RowDefinition> <RowDefinition Height="50"></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Center" FontSize="20" Text="TEST PRINT " Grid.ColumnSpan="4"/> <TextBlock HorizontalAlignment="Right" Width="120" Grid.Row="1" FontSize="12" Text="NAME:" ></TextBlock> <TextBlock HorizontalAlignment="Right" Width="120" Grid.Row="2" FontSize="12" Text="COMPANY:"></TextBlock> <TextBlock HorizontalAlignment="Right" Width="120" Grid.Row="3" FontSize="12" Text="START TIME:"></TextBlock> <TextBlock HorizontalAlignment="Right" Width="120" Grid.Row="4" FontSize="12" Text="END TIME:"></TextBlock> <TextBlock Grid.Row="1" Grid.Column="1" FontSize="12" HorizontalAlignment="Left" Text="{Binding TemplateName}"/> </Grid> </Border> </DataTemplate>
|
In other way, you can give a source when binding data like below code example,
|
<TextBlock Grid.Row="1" Grid.Column="1" FontSize="12" HorizontalAlignment="Left" Text="{Binding TemplateName,Source={StaticResource viewmodel}}"/> |
If the above one is not your requirement, could you please share the more details for whether you want to perform the print for ListBox data or SfDataGrid? This would be more helpful for us to analyze further.
Regards,
Jai Ganesh S
- 1 Reply
- 2 Participants
-
JP jenny park
- Jan 5, 2016 07:03 AM UTC
- Jan 6, 2016 01:02 PM UTC