Hi All, I want to Bind the textblock text in WPF datagrid to a dependency property. Somehow, nothing gets displayed, but when I use the same textblock binding outside the grid, everything works fine. Below is my code,
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<toolkit:DataGrid Name="definitionGrid" Margin="0,10,0,0" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="False"
RowHeight="25" FontWeight="Normal" ItemsSource="{Binding Subscription}"
ColumnHeaderStyle="{DynamicResource ColumnHeaderStyle}"
SelectionMode="Single" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Width="450"
ScrollViewer.VerticalScrollBarVisibility="Auto" Height="200">
<toolkit:DataGridCheckBoxColumn Header="Email" Width="60" Binding="{Binding ReceivesEmail}" CellStyle="{StaticResource cellCenterAlign}"/>
<toolkit:DataGridTemplateColumn Header="Others" Width="220" CellStyle="{StaticResource cellCenterAlign}" IsReadOnly="True">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=OtherSubs}"/>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
<TextBlock Text="{Binding Path=OtherSubs}"/>
</StackPanel>
Code-Behind
public string OtherSubs
{
get { return (string)GetValue(OtherSubsProperty); }
set { SetValue(OtherSubsProperty, value); }
}
public static readonly DependencyProperty OtherSubsProperty = DependencyProperty.Register("OtherSubs", typeof(string),
typeof(ProgramSubscriptions), new UIPropertyMetadata(string.Empty));
//other....
for (int i = 0; i < OtherPrgList.Count; i++)
{
foreach (int y in myList)
{
ProgramSubscriptionViewModel otheritem = OtherPrgList[i];
if (y == otheritem.Program.ID)
OtherSubs += otheritem.Subscriber.Username + ", ";
}
}
Please do let me know if there is another way that i can make this work, instead of using a dependencyproperty, althouht for testing I did put a textblock below datagrid, and it works perfectly fine..
Help!