Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check this out:</p> <p><strong>XAML:</strong></p> <pre><code>&lt;DataGrid Name="DataGrid1"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTemplateColumn&gt; &lt;DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;Button Click="ChangeText"&gt;Show/Hide&lt;/Button&gt; &lt;/DataTemplate&gt; &lt;/DataGridTemplateColumn.CellTemplate&gt; &lt;/DataGridTemplateColumn&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p><strong>Method:</strong></p> <pre><code>private void ChangeText(object sender, RoutedEventArgs e) { DemoModel model = (sender as Button).DataContext as DemoModel; model.DynamicText = (new Random().Next(0, 100).ToString()); } </code></pre> <p><strong>Class:</strong></p> <pre><code>class DemoModel : INotifyPropertyChanged { protected String _text; public String Text { get { return _text; } set { _text = value; RaisePropertyChanged("Text"); } } protected String _dynamicText; public String DynamicText { get { return _dynamicText; } set { _dynamicText = value; RaisePropertyChanged("DynamicText"); } } public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged(String propertyName) { PropertyChangedEventHandler temp = PropertyChanged; if (temp != null) { temp(this, new PropertyChangedEventArgs(propertyName)); } } } </code></pre> <p><strong>Initialization Code:</strong></p> <pre><code>ObservableCollection&lt;DemoModel&gt; models = new ObservableCollection&lt;DemoModel&gt;(); models.Add(new DemoModel() { Text = "Some Text #1." }); models.Add(new DemoModel() { Text = "Some Text #2." }); models.Add(new DemoModel() { Text = "Some Text #3." }); models.Add(new DemoModel() { Text = "Some Text #4." }); models.Add(new DemoModel() { Text = "Some Text #5." }); DataGrid1.ItemsSource = models; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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