Note that there are some explanatory texts on larger screens.

plurals
  1. PODependency Property WPF Grid
    text
    copied!<p>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,</p> <pre><code> &lt;/Grid.RowDefinitions&gt; &lt;StackPanel Grid.Row="0"&gt; &lt;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"&gt; &lt;toolkit:DataGridCheckBoxColumn Header="Email" Width="60" Binding="{Binding ReceivesEmail}" CellStyle="{StaticResource cellCenterAlign}"/&gt; &lt;toolkit:DataGridTemplateColumn Header="Others" Width="220" CellStyle="{StaticResource cellCenterAlign}" IsReadOnly="True"&gt; &lt;toolkit:DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Path=OtherSubs}"/&gt; &lt;/DataTemplate&gt; &lt;/toolkit:DataGridTemplateColumn.CellTemplate&gt; &lt;/toolkit:DataGridTemplateColumn&gt; &lt;/toolkit:DataGrid.Columns&gt; &lt;/toolkit:DataGrid&gt; &lt;TextBlock Text="{Binding Path=OtherSubs}"/&gt; &lt;/StackPanel&gt; </code></pre> <p>Code-Behind</p> <pre><code>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 &lt; OtherPrgList.Count; i++) { foreach (int y in myList) { ProgramSubscriptionViewModel otheritem = OtherPrgList[i]; if (y == otheritem.Program.ID) OtherSubs += otheritem.Subscriber.Username + ", "; } } </code></pre> <p>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! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload