Hi,
I need help to get the PropertyStatus to work on a Telerike RadGridView control. I can't get the Error Message to show up when business rule get violated. Anyone else having the similar problem.
I posted my Xaml below.
Thanks in advance.
<navigation:Page xmlns:my="clr-namespace:Csla.Xaml;assembly=Csla.Xaml" x:Class="ProMain.ExchangeRate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:csla="clr-namespace:Csla.Silverlight;assembly=Csla"
xmlns:this="clr-namespace:ProMain"
xmlns:helper="clr-namespace:ProMain"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="492" d:DesignHeight="800"
xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
>
<UserControl.Resources>
<this:ForexPlanningViewModel x:Key="ListModel"/>
<this:AuthorizationViewModel x:Key="AuthorizationModel" />
<this:AuthorizationIndConverter x:Key="AuthorizationIndConverter" />
<this:IntegerBooleanConverter x:Key="IntBooleanConverter" />
<this:DecimalEmptyStringConverter x:Key="DecimalConverter" />
<this:FirstOfMonthValueConverter x:Key="FirstOfMonthConverter" />
<this:Command x:Key="load" Method="Load" />
<this:Command x:Key="save" Method="Save" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Height="Auto">
<StackPanel Height="Auto">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Height="Auto" DataContext="{Binding Source={StaticResource ListModel}}">
<StackPanel Orientation="Horizontal" DataContext="{Binding Source={StaticResource AuthorizationModel},Path=Model,Mode=TwoWay}">
<TextBox x:Name="AuthorizationIndicator" Text="{Binding Path=AuthorizationInd, Mode=OneWay}"
IsReadOnly="{Binding Path=IsReadOnly}"/>
</StackPanel>
<TextBlock Text="From:" Margin="4,3,4,0"/>
<telerikInput:RadMaskedTextBox Name="forexFromRadMaskedTextBox" Value="{Binding Source={StaticResource ListModel}, Path=FromDt, Mode=TwoWay}" MaskType="DateTime" Mask="MM/yyyy" Height="10" Margin="3,3,0,3" Width="60"/>
<telerikInput:RadDatePicker Name="forexFromRadDatePicker" Width="15" SelectedDate="{Binding Source={StaticResource ListModel}, Path=FromDt, Mode=TwoWay}" Margin="0,3,3,3" />
<TextBlock Text="Thru:" Margin="4,3,4,0" />
<telerikInput:RadMaskedTextBox Name="forexToRadMaskedTextBox" Value="{Binding Source={StaticResource ListModel}, Path=ThruDt, Mode=TwoWay}" MaskType="DateTime" Mask="MM/yyyy" Height="10" Margin="3,3,0,3" Width="60"/>
<telerikInput:RadDatePicker Name="forexToRadDatePicker" Width="15" SelectedDate="{Binding Source={StaticResource ListModel}, Path=ThruDt, Mode=TwoWay}" Margin="0,3,3,3" />
<my:TriggerAction
TargetControl="{Binding ElementName=LoadButton}"
MethodName="Load"
TriggerEvent="Click" >
</my:TriggerAction>
<my:TriggerAction
TargetControl="{Binding ElementName=SaveButton}"
MethodName="Save"
TriggerEvent="Click" >
</my:TriggerAction>
<Button x:Name="LoadButton" Content="Load" Width="70" Margin="4,0,0,0" HorizontalAlignment="Left"
Tag="{Binding ElementName=radGridView1}" >
</Button>
<Button x:Name="SaveButton" Content="Save" Width="70" Margin="4,0,0,0" HorizontalAlignment="Left"
Tag="{Binding ElementName=radGridView1}"
>
</Button>
</StackPanel>
<StackPanel Height="Auto">
<telerikGridView:RadGridView Grid.RowSpan="2" HorizontalAlignment="Left" Margin="3,3,0,0" Height="500" Width="Auto"
Name="radGridView1" VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource ListModel}, Path=Model, Mode=TwoWay}"
AutoGenerateColumns="False" IsBusy="{Binding Source={StaticResource ListModel}, Path=IsBusy}"
AlternateRowBackground="LightGray" ScrollViewer.VerticalScrollBarVisibility="Auto"
IsReadOnly="{Binding ElementName=AuthorizationIndicator,Path=IsReadOnly}"
SelectedItem="{Binding Source={StaticResource ListModel}, Path=SelectedRate, Mode=TwoWay}" ShowGroupPanel="False" IsScrolling="False">
<telerikGridView:RadGridView.Columns>
<telerikGridView:GridViewDataColumn Header="Currency" DataMemberBinding="{Binding CurrencyCd}" IsReadOnly="True" >
</telerikGridView:GridViewDataColumn>
<telerikGridView:GridViewDataColumn Header="Effective Dt" DataMemberBinding="{Binding EffectiveDt}" IsReadOnly="True" DataFormatString="{}{0:MM/dd/yyyy}"/>
<telerikGridView:GridViewDataColumn x:Name="PlanRateTextBox" Header="Plan Rate" DataMemberBinding="{Binding PlanRate, Converter={StaticResource DecimalConverter}, Mode=TwoWay}"
/>
<telerikGridView:GridViewDataColumn Header="Actual Rate" DataMemberBinding="{Binding ActualRate, Converter={StaticResource DecimalConverter}, Mode=TwoWay}"
/>
<telerikGridView:GridViewDataColumn Header="Another Plan">
<telerikGridView:GridViewDataColumn.CellEditTemplate>
<DataTemplate>
<my:PropertyStatus Foreground="Red" Background="Yellow" Property="{Binding PlanRate}" Margin="5" TargetControl="{Binding ElementName=PlanRateTextBox}" DataContext="{Binding Source={StaticResource ListModel}}" />
</DataTemplate>
</telerikGridView:GridViewDataColumn.CellEditTemplate>
</telerikGridView:GridViewDataColumn>
</telerikGridView:RadGridView.Columns>
</telerikGridView:RadGridView>
</StackPanel>
</StackPanel>
</Grid>
</navigation:Page>
PropertyStatus needs its DataContext to be the business object, not the viewmodel.
Thanks for the prompt reply.
I changed my DataContext to point to the business object but still not getting the error message. Do you have an example for me to follow in Silverlight using CSLA 4 and MVVM? This is the remaining piece in my demo that is not working properly.
Thanks again.
Hi I am using Silverlight 4 - CSLA 4.0.1 - MVVM.
I had the same issue a couple weeks ago. It turned out that I was missing base.AddBusinessRules() in the AddBusinessRules method of my BusinessBase object. I Added this line and the XAML propertystatus control is now working properly on the UI.
#region Business Rules
protected override void AddBusinessRules()
{
// TODO: add validation rules
base.AddBusinessRules();
//BusinessRules.AddRule(new Rule(), MyProperty);
}
#endregion
Hope this solves your problem.
Copyright (c) Marimer LLC