나는 작업중인 프로그램의 ViewModel을 파악하려고합니다. 나는 전에 이것을 한 적이 없다. 다음은 ViewModel
이 필요한 Switch
개체의 부분 클래스 정의와 지금까지 가지고있는 XAML입니다. 나는 XAML이 더 많이 필요하다는 것을 알고있다.처음으로 ViewModel 빌드
지금 바로 열기 전에 데이터로 SwitchBrowser
창을 채우기 위해 코드 숨김 작업을하고 있습니다. ObservableCollection
을 XAML에 바인딩하는 것이 더 쉽다는 것을 알고 있습니다.
ObservableCollection
에 CiscoSwitch
개체를 저장하고 Switch
개체의 속성에 직접 바인딩 할 수 있습니까?
그렇다면, 나는 CiscoSwitch
에 ModulesList
에 XAML에 ModulesTreeview
에 ItemsSource
을 설정하는 등의 일을 할 수 있습니까? 지금은 ModulesTreeView
을 채우기 위해 코드 숨김에 foreach를 사용하고 있습니다.
ObservableCollection
을 SwitchModules
으로 작성한 다음 VSANs
을 다른 것으로 작성 하시겠습니까?
public partial class CiscoSwitch
{
#region baseswitchclassproperties
private string _SwitchName = String.Empty;
public string switchName{ get{return _SwitchName;} set{_SwitchName=value;} } private string _SWVersion = String.Empty;
public string swVersion{ get{return _SWVersion;} set{_SWVersion=value;} }
private string _SwitchModel = String.Empty;
public string switchModel { get{return _SwitchModel;} set{_SwitchModel=value;} }
private string _SerialNumber = String.Empty;
public string SerialNumber { get { return _SerialNumber; } set { _SerialNumber = value; } }
private string _SwitchWWPN = string.Empty;
public string SwitchWWPN { get { return _SwitchWWPN; } set { _SwitchWWPN = value; } }
public Dictionary<int, SwitchModule> ModuleList = new Dictionary<int, SwitchModule>();
public Dictionary <int, CiscoVSAN> VSANList = new Dictionary<int, CiscoVSAN>();
protected EthernetPort _ManagementPort = new EthernetPort();
public string IPAddress{ set{_ManagementPort.IPAddress=value;} get{return _ManagementPort.IPAddress;} }
public string LastDataCaptureDate = null;
public Dictionary<int, PortChannel> PortChanelList = new Dictionary<int, PortChannel>();
public Dictionary<String, FCIPPort> FCIPPortList = new Dictionary<string, FCIPPort>();
public InterVSANTopology IVRTopology = null; //new InterVSANTopology();
public Dictionary<int, List<CiscoSwitch>> NeighborsList = new Dictionary<int, List<CiscoSwitch>>();
public Dictionary<string, string> DeviceAliases = new Dictionary<string, string>();
public Dictionary<string, FCPort> FlogiDatabase = new Dictionary<string, FCPort>();
#endregion
}
XAML : 단일 ObservableCollection<CiscoSwitch>
를 만드는 방법에 대한
<Window.Resources>
<Style TargetType="{x:Type TreeViewItem}" x:Key="ModuleStyle">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontSize" Value="12"/>
</Style>
<Style TargetType="{x:Type TreeViewItem}" x:Key="RedModuleStyle" BasedOn="{StaticResource ModuleStyle}">
<Setter Property="Foreground" Value="Red"/>
</Style>
</Window.Resources>
<Grid Margin="0,0,-211.4,-168">
<StackPanel HorizontalAlignment="Stretch" Name="StackPanel1" VerticalAlignment="Stretch" Width="Auto" Margin="0,0,188.6,114">
<StackPanel.Resources>
<Style TargetType="{x:Type Label}" x:Key="LabelStyle">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</StackPanel.Resources>
<Label Content="Switch Name:" Name="Label1" Height="25" HorizontalAlignment="Left"/>
<Label Content="Software Version:" Name="Label2" HorizontalAlignment="Left" />
<Label Content="Model Number:" Name="Label3" HorizontalAlignment="left"/>
<Label Content="IP Address:" Name="Label4" HorizontalAlignment="left"></Label>
<Label Content="Serial Number:" Name="Label5" HorizontalAlignment="Left"></Label>
<Label Content="Show Tech Taken:" Name="Label6" HorizontalAlignment="left"/>
</StackPanel>
<StackPanel Margin="105,0,15.6,114">
<StackPanel.Resources>
<Style TargetType="{x:Type Label}" x:Key="LabelStyle">
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</StackPanel.Resources>
<Label Content="Name" Name="SwitchNameLabel" HorizontalAlignment="left"/>
<Label Content="Version" Name="VersionLabel" HorizontalAlignment="left"/>
<Label Content="Model" Name="ModelNumberLabel" HorizontalAlignment="Left"/>
<Label Content="IP" Name="IPAddressLabel" HorizontalAlignment="Left"/>
<Label Content="Serial" Name="SerialLabel" HorizontalAlignment="Left"/>
<Label Content="ST" Name="ShowTechLabel" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Height="Auto" Margin="0,156,0,0" VerticalAlignment="Top" Width="256" >
<TreeView Name="ModulesTreeView" Height="auto" Background="GhostWhite" BorderThickness="0"/>
</StackPanel>
</Grid>
감사합니다. 나는 그것의 일부가 작동하도록했다. –
기꺼이 도와 드리겠습니다. –