如何在不使用mvvm的情况下在Silverlight中实现货币管理? [英] How to implement currency management in Silverlight without using mvvm?
问题描述
我需要具有与Windows窗体中使用的BindingSource类似的功能。假设我们有一个数据网格和文本框都绑定到相同的数据表。在选择更改数据网格时,我想要更改文本框值。
这是在windows窗体中工作..我需要在银灯中实现相同的功能。
<代码样式="边距:0px;填充:0px;边框:0px;字体大小:13px;字体系列:Consolas,Menlo,Monaco,'Lucida控制台','解放单声道','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif; white-space :inherit"> <网格 样式 = " { StaticResource GridStyle } " HorizontalAlignment = " Stretch" >
< Grid.RowDefinitions>
< RowDefinition 高度 = " *" />
< /Grid.RowDefinitions>
<网格 网格 。 行 = " 0" >
< Grid.RowDefinitions>
< RowDefinition 高度 = " *" />
< RowDefinition 高度 = " *" />
< /Grid.RowDefinitions>
< c1grid:C1DataGrid x:FieldModifier = "公共" HorizontalScrollBarVisibility = " Auto" 网格 。 行 = " 1" x:名称 = " gridTest" 样式 = " { StaticResource DataGridStyle } "
MouseRightButtonUp = " gridTest_MouseRightButtonUp"
MouseRightButtonDown = " gridTest_MouseRightButtonDown" >
< c1grid:C1DataGrid.Columns>
< c1grid:DataGridTextColumn 标题 = " {Binding Strings.strhdrSubcaseID,Source = {StaticResource localization}}" 绑定 = " {Binding Path = SUBINCIDENT__ID_NUMBER}" FilterMemberPath = " SUBINCIDENT__ID_NUMBER" SortMemberPath = " SUBINCIDENT__ID_NUMBER" />
< c1grid:DataGridTextColumn 标题 = " {Binding Strings.strhdrWOStage,Source = {StaticResource localization}}" 绑定 = " {Binding Path = WORK_ORDER__STATUS}" FilterMemberPath = " WORK_ORDER__STATUS" SortMemberPath = " WORK_ORDER__STATUS" />
< c1grid:DataGridTextColumn 标题 = " {Binding Strings.strhdrSLACondition,Source = {StaticResource localization}}" 绑定 = " {Binding Path = WORK_ORDER__CONDITION}" FilterMemberPath = " WORK_ORDER__CONDITION" SortMemberPath = " WORK_ORDER__CONDITION" />
< c1grid:DataGridTextColumn 标题 = "状态" 绑定 = " {Binding Path = STATUS}" FilterMemberPath = " STATUS" SortMemberPath = " STATUS" 可见性 = " Collapsed" />
< / c1grid:C1DataGrid.Columns>
< / c1grid:C1DataGrid>
< TextBox x:名称 = " txt_IDNumber" 文字 = " {Binding Path = SUBINCIDENT__ID_NUMBER}" 网格 。 行 = " 0" 网格 。 列 = " 4" TextWrapping = " Wrap" 保证金 = " 4,0,0,4" VerticalAlignment = " Stretch"
高度 = " 22" FontSize = " 11" 样式 = " { StaticResource TextboxStyle } " />
< / Grid>
< / Grid>
我没有使用MVVM或MVP模式。
嗨asritha.reddy,
据我所知,我们无法绑定列表在Silverlight应用程序的TextBox中。
根据您的描述,当在DataGrid控件中选择相关项时,您希望在TextBox中显示SUBINCIDENT__ID_NUMBER属性,是不是?
我们只需要为DataGrid添加一个SelectionChanged事件,然后在此事件中更改Text属性以显示SUBINCIDENT__ID_NUMBER。以下示例代码实现您的要求。希望可以帮助您。
< sdk:DataGrid HorizontalScrollBarVisibility =" Auto" Grid.Row =" 1" x:Name =" gridTest" SelectionChanged =" gridTest_SelectionChanged" > ;< / sdk:DataGrid>
< TextBox x:Name =" txt_IDNumber" T EXT ="" Grid.Row = QUOT; 0" Grid.Column = QUOT; 4英寸TextWrapping = QUOT;包覆与QUOT;余量= QUOT; 4,0,0,4" VerticalAlignment = QUOT;拉伸"
Height =" 22"字号= QUOT 11 QUOT; />
private void gridTest_SelectionChanged(object sender,SelectionChangedEventArgs e)
{
TestData selected =(TestData)gridTest.SelectedItem;
txt_IDNumber.Text = selected.SUBINCIDENT__ID_NUMBER;
}最好的问候,
Weiwei
I need to have similar functionality as BindingSource we use in windows forms. Suppose we have a data grid and text box both are bind with same data table. On the selection change of the data grid i would like to text box value to be changed.
This is working in windows forms.. I need to implement same functionality in silver light.
<Grid Style="{StaticResource GridStyle}" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<c1grid:C1DataGrid x:FieldModifier="Public" HorizontalScrollBarVisibility="Auto" Grid.Row="1" x:Name="gridTest" Style="{StaticResource DataGridStyle}"
MouseRightButtonUp="gridTest_MouseRightButtonUp"
MouseRightButtonDown="gridTest_MouseRightButtonDown" >
<c1grid:C1DataGrid.Columns>
<c1grid:DataGridTextColumn Header="{Binding Strings.strhdrSubcaseID, Source={StaticResource localization}}" Binding="{Binding Path=SUBINCIDENT__ID_NUMBER}" FilterMemberPath="SUBINCIDENT__ID_NUMBER" SortMemberPath="SUBINCIDENT__ID_NUMBER"/>
<c1grid:DataGridTextColumn Header="{Binding Strings.strhdrWOStage, Source={StaticResource localization}}" Binding="{Binding Path=WORK_ORDER__STATUS}" FilterMemberPath="WORK_ORDER__STATUS" SortMemberPath="WORK_ORDER__STATUS"/>
<c1grid:DataGridTextColumn Header="{Binding Strings.strhdrSLACondition, Source={StaticResource localization}}" Binding="{Binding Path=WORK_ORDER__CONDITION}" FilterMemberPath="WORK_ORDER__CONDITION" SortMemberPath="WORK_ORDER__CONDITION"/>
<c1grid:DataGridTextColumn Header="Status" Binding="{Binding Path=STATUS}" FilterMemberPath="STATUS" SortMemberPath="STATUS" Visibility="Collapsed"/>
</c1grid:C1DataGrid.Columns>
</c1grid:C1DataGrid>
<TextBox x:Name="txt_IDNumber" Text="{Binding Path=SUBINCIDENT__ID_NUMBER}" Grid.Row="0" Grid.Column="4" TextWrapping="Wrap" Margin="4,0,0,4" VerticalAlignment="Stretch"
Height="22" FontSize="11" Style="{StaticResource TextboxStyle}" />
</Grid>
</Grid>
I'm not using MVVM OR MVP pattern.
Hi asritha.reddy,
As far as I know, we could not bind a list in TextBox in Silverlight application.
According to your description, you want to show the SUBINCIDENT__ID_NUMBER property in TextBox when the related Item is selected in DataGrid control, is it right?
We just need to add a SelectionChanged event for DataGrid and then change the Text property in this event to show the SUBINCIDENT__ID_NUMBER. Following sample code implement your requirement。 Hope that can help you.
<sdk:DataGrid HorizontalScrollBarVisibility="Auto" Grid.Row="1" x:Name="gridTest" SelectionChanged="gridTest_SelectionChanged"></sdk:DataGrid> <TextBox x:Name="txt_IDNumber" Text="" Grid.Row="0" Grid.Column="4" TextWrapping="Wrap" Margin="4,0,0,4" VerticalAlignment="Stretch" Height="22" FontSize="11" />
private void gridTest_SelectionChanged(object sender, SelectionChangedEventArgs e) { TestData selected = (TestData)gridTest.SelectedItem; txt_IDNumber.Text = selected.SUBINCIDENT__ID_NUMBER; }Best Regards,
Weiwei
这篇关于如何在不使用mvvm的情况下在Silverlight中实现货币管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!