私はいくつかのデータソースにバインドするにはどうすればよいカスタムクラスをWPFでバインド可能にするにはどうすればいいですか?
internal class PageInformation : DependencyObject
{
public static DependencyProperty NameProperty =
DependencyProperty.Register("Name", typeof(string), typeof(PageInformation));
public static DependencyProperty PageUriProperty =
DependencyProperty.Register("PageUri", typeof(string), typeof(PageInformation));
public string Name
{
get;
set;
}
public Uri PageUri
{
get;
}
}
、クラスを持っていますか?
私の考えは、アプリケーション内のすべてのページに関する情報を格納するXMLファイルを持ち、このクラスを<Page.Resources>
にしてXMLファイルにバインドすることです。
XMLファイルには、次のようになります。私が持っていると思います
<Elements>
<Element Name="Administration" DisplayName="Administration" Value="1" PageUri="Administration.xaml" >
<Element Name="Categories" DisplayName="Categories" Value="2" PageUri="Administration.xaml" ></Element>
<Element Name="Goals" DisplayName="Goals" Value="3" PageUri="Administration.xaml" ></Element>
<Element Name="Settings" DisplayName="Settings" Value="4" PageUri="Administration.xaml" ></Element>
</Element>
</Elements>
は次のようにXAMLを持っている:
<Page.Resources>
<local:PageInformation
x:Key="pageInfo"
Name="{Binding XPath=/Elements/Element[@Name='Administration']}"
Source="/samples.xml" >
</local:PageInformation>
</Page.Resources>
を私はName
プロパティの値を持っている場合は、私が移入するためのコードを書きたいです他のプロパティも(おそらくデータコンテキストを使用して?)。
どうすればいいですか? Nameプロパティの変更コードを実行するには