Search Results

Search found 4 results on 1 pages for 'rodd'.

Page 1/1 | 1 

  • How to tell which dataform button ended edit when using EventToCommand

    - by Rodd
    I'm new to SilverLight and Mvvm-Light. I have a DataForm on my view that displays/edits a SelectedPerson property (a Person object) of my view model. I want to execute a command on my viewmodel when the user clicks the Save button but don't want to take action if the user clicks cancel. I added the following to my ViewModel: public RelayCommand PersonEditEnded {get; set;} ... public void Initialize() { PersonEditEnded = new RelayCommand(DoSomething); ... } public void DoSomething() { } I added the following to my View: <toolkit:DataForm x:Name="PersonForm" ... CurrentItem="{Binding SelectedPerson, Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="EditEnded"> <gs:EventToCommand Command="{Binding PersonEditEnded, Mode=OneWay}"/> </i:EventTrigger> </i:Interaction.Triggers> </toolkit:DataForm> This works and the DoSomething method is being called when the user presses Submit. However, DoSomething is also called when user presses Cancel. Is there a way to know which button was pressed or to supress the call when Cancel is pressed? Thanks for whatever help you can offer!

    Read the article

  • Attached property and style missing on re adding the user control

    - by RodD
    Hey people I've got an issue with a WPF project I'm working on, I have an items control which I add to and remove from certain user controls, these contols styles and attached properties are there on first view but when I remove and add them again the user control apears on screen but is detached from the items control attached properties and styles. Is this behaviour common and if so what is the best way to handle it? Thanks in advance

    Read the article

  • How do I change the visual style of a listitem based on its bound value?

    - by Rodd
    I have a listbox (here's the xaml): <ListBox MinWidth="300" ItemsSource="{Binding Relationships, Mode=OneWay}" SelectedItem="{Binding SelectedRelationship, Mode=TwoWay}" SelectionMode="Single" HorizontalAlignment="Left" > <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <CheckBox IsChecked = "{Binding IsPrimary}" IsHitTestVisible="False" /> <StackPanel Orientation="Horizontal" Grid.Column="1"> <TextBlock Text="{Binding RelationshipType}" FontWeight="Bold" Margin="0,0,5,0" /> <TextBlock Text="{Binding Status}" FontStyle="Italic" /> </StackPanel> <TextBlock Text="{Binding UnitName}" Grid.Row="1" Grid.Column="1" /> <TextBlock Text="{Binding StartDate, Converter={StaticResource DateConverter}}" Grid.Row="2" Grid.Column="1"/> <TextBlock Text="{Binding RetireDate}" Grid.Row="3" Grid.Column="1" /> <TextBlock Text="{Binding EndDate}" Grid.Row="4" Grid.Column="1" /> <TextBlock Text="{Binding ReasonForLeaving}" Grid.Row="5" Grid.Column="1" /> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> What I want to do is have each item in the listbox have one of 3 backgrounds (green if the value of IsPrimary = true, Orange if the EndDate value is empty and grey if the EndDate value is not empty. Is there a way to template the listbox items so that they evaluate bound items to determine a view state or to have each listbox item bind to a value that I can set for each item in my viewmodel? Thanks for your help.

    Read the article

1