This is a migrated thread and some comments may be shown as answers.

Manipulate the Dynamic viewmodel

1 Answer 82 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 25 Mar 2013, 02:30 PM
When I select a value in a combobox I want to update a value on the dynamic viewmodel

I have this template:

<DataTemplate x:Key="RequiredCondition">
       <telerik:RadComboBox ItemsSource="{Binding Path=DataContext.Conditions, RelativeSource={RelativeSource FindAncestor,
                                              AncestorType={x:Type views:PropertyEditorView}}, Mode=OneWay}"
                            DisplayMemberPath="Name"
                            SelectedItem="{Binding CurrentPropertySet[RequiredCondition]}"
                            ToolTip="{Binding ElementName=cboRequiredCondition, Path=SelectionBoxItem.Description}"
                            ClearSelectionButtonContent="Clear"
                            ClearSelectionButtonVisibility="Visible"
                            TextSearchMode="Contains"
                            x:Name="cboRequiredCondition"/>
   </DataTemplate>

And when the selecting changes i want to do some stuff, Can I do this from within a template?

Right now I am having two problems. 
The clear button on the RadComboBox is not setting the value on my model and because I am using IntersectionMode = Dynamic viewmodel I can not use my model to execute the logic

public Condition VisibleCondition
      {
          get
          {
              if (Conditions.Count > 0 && _visibleCondition == null)
              {
                  _visibleCondition = Conditions.SingleOrDefault(x => x.Action == Condition.Actions.SET_IS_VISIBLE);
                  IsVisible = _visibleCondition == null;
              }
              return _visibleCondition;
          }
          set
          {
              if (_visibleCondition != value)
              {
                  IsVisible = value == null;
 
                  // remove the old condition
                  if (Conditions.Contains(_visibleCondition))
                      Conditions.Remove(_visibleCondition);
 
                  // add the new condition
                  _visibleCondition = value;
                  Conditions.Add(_visibleCondition);
                  IsVisible = _visibleCondition == null;
              }
          }
      }

Normal when I set IsVisible I will get a NotifyPropertyChanged (using Fody https://github.com/Fody/PropertyChanged.)
I am very close to my goal but I am unable to go the rest of the way alone (-.

Will it help if I have the depended properties in the same template?. 

 

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 28 Mar 2013, 03:17 PM
Hello,

 Will it be possible for you to send us a sample project as it is extremely difficult for us to reproduce your scenario by having only few code snippets?

Kind regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
Martin
Top achievements
Rank 2
Answers by
Ivan Ivanov
Telerik team
Share this question
or