【发布时间】:2014-09-24 11:36:06
【问题描述】:
我是 WPF 和 MVVM 结构的初学者。以下是我查看部分和相关文件的代码:
ListOfVehicle
<Window x:Class="Seris.ListOfVehicle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ListOfVehcle" Height="600" Width="700"
xmlns:cnv="clr-namespace:Seris.Converters">
<Window.Resources>
<cnv:ID2Name x:Key="converter" />
</Window.Resources>
<Grid HorizontalAlignment="Center">
<Label Content="Manage Vehicle" HorizontalAlignment="Left" Height="27" Margin="261,8,0,0" VerticalAlignment="Top" Width="103" FontWeight="Bold" FontSize="12"/>
<Label Content="SERIS CAD" HorizontalAlignment="Left" Height="30" Margin="53,8,0,0" VerticalAlignment="Top" Width="84" FontWeight="Bold"/>
<Menu x:Name="ListOfPersonnnel" HorizontalAlignment="Left" Height="32" Margin="10,35,0,0" VerticalAlignment="Top" Width="603">
<MenuItem Header="Manage Vehicle >>" />
</Menu>
<Button Name="Add_Button" CommandParameter="add" Command="{Binding OpenAddWindow_Command}" Content="Add" Height="28" Width="81" Margin="246,396,315,46"/>
<Button Name="Replace_Button" CommandParameter="replace" Command="{Binding ReplaceButton_Command}" IsEnabled="{Binding IsEnableReplaceButton, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Content="Replace" Height="28" Width="81" Margin="345,396,216,46"/>
<Button Name="Remove_Button" CommandParameter="remove" Command="{Binding RemoveButton_Command}" IsEnabled="{Binding IsEnableReplaceButton, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Content="Remove" Height="28" Width="81" Margin="442,396,119,46"/>
<ListView Name ="Grid" Margin="104,67,185,226" >
<DataGrid Name="DG" ItemsSource="{Binding ListItems, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedRow, Mode=TwoWay}" SelectionMode="Single" GridLinesVisibility="None" IsReadOnly="True" AutoGenerateColumns="False" BorderThickness="0">
<DataGrid.Columns>
<DataGridTextColumn Header="Vehicle No" Binding="{Binding VehicleNo}"/>
<DataGridTextColumn Header="Model" Binding="{Binding Model}" />
<DataGridTextColumn Header="ManufacturingDate" Binding="{Binding ManufacturingDate}" />
<DataGridTextColumn Header="IUNo" Binding="{Binding IUNo}" />
<DataGridTextColumn Header="Personnel" Binding="{Binding PersonnelNameSelected, Converter={StaticResource converter} }" />
<DataGridTextColumn Header="Unique No" Binding="{Binding UniqueNo}"/>
</DataGrid.Columns>
</DataGrid>
</ListView>
</Grid>
</Window>
做完这些后,我卡在了一个点。我需要的是如下,但不知道如何实现。
假设,我在视图部分放了 2 个文本框和一个标签。 (分别考虑TextBox1、TextBox2和Label)
我需要的是非常小的 WPF C# 示例,这样当我单击特定的文本框时,它会在标签中提供内容以及该文本框的名称。
即名称是“TextBox1”,内容是“你好吗?”
【问题讨论】:
-
听起来你差点给我们布置任务。你的尝试在哪里?
-
Kindly put some effort into programming first。如果您询问您的代码的具体问题,我相信人们会很乐意提供帮助...
-
看看这里:code.msdn.microsoft.com。我什至在searchbox 中为你写了 WPF。
-
其实我正在做一个学习WPF的应用程序,只剩下这个功能。这就是为什么。如果你需要,我可以放我的一堆文件,但对你没有用。
-
那就不要放那一堆对我们没用的文件。只需向我们展示代码的相关摘录即可。