XAML less..
<Window x:Class="WpfApplication4.Window1"
xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml "
Title="ExampleCS"
Loaded="Window1_Loaded"
>
<StackPanel>
<TextBlock HorizontalAlignment="Center"
FontWeight="Bold">
BlogEditor
</TextBlock>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<ListBox Name="entry" />
<ListBox Name="entryListBox"
Height="300"
SelectionChanged="entryListBox_Changed"/>
<Grid Width="500" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="*" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0">Title:</TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Name="titleText" />
<TextBlock Grid.Row="1" Grid.Column="0">Url:</TextBlock>
<TextBox Grid.Row="1" Grid.Column="1" Name="urlText" />
<TextBlock Grid.Row="2" Grid.Column="0">Date:</TextBlock>
<TextBox Grid.Row="2" Grid.Column="1" Name="dateText" />
<TextBlock Grid.Row="3" Grid.Column="0">Body:</TextBlock>
<TextBox Grid.Row="3" Grid.Column="1"
Name="bodyText"
TextWrapping="Wrap" />
<Button Grid.Row="4"
Grid.ColumnSpan="2"
Grid.Column="1"
Click="updateButton_Click">
Update
</Button>
</Grid>
</StackPanel>
</StackPanel>
</Window>
XAML less..
cs less..
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Xml;
namespace WpfApplication4 { /// <summary> /// Window1.xaml에 대한 상호 작용 논리 /// </summary> public partial class Window1 : Window { XmlDocument blog = new XmlDocument(); const string BLOGURL = @"rss.rss";
public Window1() { InitializeComponent(); blog.Load(BLOGURL); }
void Window1_Loaded(object sender, RoutedEventArgs e) { FillListBox(); }
void FillListBox() { entryListBox.Items.Clear();
XmlNodeList nodes = blog.SelectNodes("//item"); foreach (XmlNode node in nodes) { ListBoxItem item = new ListBoxItem(); item.Tag = node; item.Content = node["title"].InnerText; entryListBox.Items.Add(item); } } void entryListBox_Changed(object sender, RoutedEventArgs e) { if (entryListBox.SelectedIndex != -1) { XmlNode node = ((ListBoxItem)entryListBox.SelectedItem).Tag as XmlNode; if (node != null) { titleText.Text = node["title"].InnerText; urlText.Text = node["guid"].InnerText; dateText.Text = node["pubDate"].InnerText; bodyText.Text = node["description"].InnerText; } } }
void updateButton_Click(object sender, RoutedEventArgs e) { if (entryListBox.SelectedIndex != -1) { XmlNode node = ((ListBoxItem)entryListBox.SelectedItem).Tag as XmlNode; if (node != null) { node["title"].InnerText = titleText.Text; node["guid"].InnerText = urlText.Text; node["pubDate"].InnerText = dateText.Text; node["description"].InnerText = bodyText.Text;
blog.Save(BLOGURL);
FillListBox(); } } }
} }
cs less.. 이게 아마 msdn에 나온 예제 일꺼예요.. 아까 링크를 날려서 어디서 펐는지 모르겠어요..
댓글 영역