親愛なる、
Autodesk DataStandardアドインのUIをカスタマイズして、XMLの世界に入ります。
A ComboBox1のは、アイテムが取り込まれるべきStandardTextInfoは、 XMLファイルにリストされています。各アイテムは、次のプロパティで構成されています。-
StandardTextNumber-
StandardTextDE
-StandardTextEN
-StandardTextFR
ここでStandardText.XMLのファイル:
<?xml version="1.0" encoding="utf-8"?>
<StandardTextData xmlns="">
<StandardTextInfo StandardTextNumber="10" DE="KATZE" EN="CAT" FR="CHAT"></StandardTextInfo>
<StandardTextInfo StandardTextNumber="20" DE="HUND" EN="DOG" FR="CHIEN"></StandardTextInfo>
<StandardTextInfo StandardTextNumber="30" DE="PFERD" EN="HORSE" FR="CHEVAL"></StandardTextInfo>
</StandardTextData>
A Combobox2はアイテムが取り込まれるべきLanguageInfoは、 XMLファイルにリストされています。各アイテムは、LanguageNameプロパティ(DE = Deutsch、EN = English、FR = Francais)で構成されています。これがLanguage.XMLファイルです:
<?xml version="1.0" encoding="utf-8"?>
<LanguageData xmlns="">
<LanguageInfo LanguageName="DE"></LanguageInfo>
<LanguageInfo LanguageName="EN"></LanguageInfo>
<LanguageInfo LanguageName="FR"></LanguageInfo>
</LanguageData>
使用目的は次のとおりです
。-ユーザーは、Combobox2から、アイテムがCombobox1に表示される言語を選択します。-Combobox1 DisplayMemberPathに
表示される値は、Combobox2で選択された値に対応するitemsプロパティにバインドされている必要があります。したがって、アイテム名は、ユーザーが選択した言語で表示できます。-Beside、Combobox3のディスプレイプロパティStandardTextNumberで選択された項目のComboBox1の。ラベルではなくコンボボックス(Combobox3について説明します)を使用することで、ユーザーはアイテムプロパティStandardTextNumberを直接選択することもできます。
、Combobox1に表示されているアイテムを逆に更新します(Combobox2で定義されている言語のままです)。
XAMLファイルへの3つのコンボボックスの定義は次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<WPF:MainWindow>
x:Name="FileWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WPF="clr-namespace:CreateObject.WPF;assembly=CreateObject"
<Window.Resources>
<XmlDataProvider>
x:Key="Languages"
Source="C:\Language.xml"
XPath="/LanguageData"
</XmlDataProvider>
<XmlDataProvider
x:Key="StandardTexts"
Source="C:\StandardText.xml"
XPath="/StandardTextData"
</XmlDataProvider>
</Window.Resources>
<ComboBox>
x:Name="Combobox1"
IsEnabled="{Binding CreateMode}"
ItemsSource="{Binding Source={StaticResource StandardTexts}, XPath="StandardTextInfo"}"
SelectedItem="{Binding SelectedItem, ElementName=ComboBox3, Mode=OneWay}"
SelectedValue="{Binding SelectedValue, ElementName=ComboBox2, Mode=OneWay}"
SelectedValuePath="@StandardTextNumber"
DisplayMemberPath="{Binding SelectedValue, ElementName=ComboBox3, Mode=OneWay}"
</ComboBox>
<ComboBox>
x:Name="Combobox2"
IsEnabled="{Binding CreateMode}"
ItemsSource="{Binding Source={StaticResource Languages}, XPath="LanguageInfo"}"
SelectedValue="{Binding Prop[LanguageName].value}"
SelectedValuePath="@LanguageName"
DisplayMemberPath="@LanguageName"
</ComboBox>
<ComboBox>
x:Name="Combobox3"
IsEnabled="{Binding CreateMode}"
ItemsSource="{Binding Source={StaticResource StandardTexts}, XPath="StandardTextInfo"}"
SelectedItem="{Binding SelectedItem, ElementName=ComboBox1, Mode=OneWay}"
SelectedValue="{Binding SelectedValue, ElementName=ComboBox2, Mode=OneWay}"
SelectedValuePath="{Binding SelectedValue, ElementName=ComboBox1, Mode=OneWay}"
DisplayMemberPath="@StandardTextNumber"
</ComboBox>
</WPF:MainWindow>
私の質問:
1)Combobox1 SelectedValue&DisplayMemberPath、Combobox3 SelectedValue&SelectedValuePath:おそらくロジックが恋しいです:目的のバインディングをどのように表現する必要がありますか?
2)XMLでは、バインドされたプロパティの額にあるプレフィックス@の目的は何ですか?
3)ソースLanguage.XMLは実際には必要ないと確信しています:ソースStandardText.XML内で識別された言語から直接Combobox2にデータを入力することは可能ですか?
4)どのような状況でIsEnabledプロパティをCreateModeまたはEditModeに設定する必要がありますか?
親切なアドバイスをよろしくお願いします。
よろしく、レオン
質問1への回答:
StandardText.XMLおよびLanguage.XMLファイルは変更されません(上記の投稿の説明を参照)
3つのコンボボックスのFile.XAMLまたはInventor.XAMLファイルへの変更(申し訳ありませんが、変更を強調表示できません):
<?xml version="1.0" encoding="utf-8"?>
<WPF:MainWindow>
x:Name="FileWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WPF="clr-namespace:CreateObject.WPF;assembly=CreateObject"
<Window.Resources>
<XmlDataProvider>
x:Key="Languages"
Source="C:\Language.xml"
XPath="/LanguageData"
</XmlDataProvider>
<XmlDataProvider
x:Key="StandardTexts"
Source="C:\StandardText.xml"
XPath="/StandardTextData"
</XmlDataProvider>
</Window.Resources>
<ComboBox>
x:Name="Combobox1"
IsEnabled="{Binding CreateMode}"
ItemsSource="{Binding Source={StaticResource StandardTexts}, XPath="StandardTextInfo"}"
SelectedItem="{Binding SelectedItem, ElementName=ComboBox3, Mode=OneWay}"
# SelectedValue: no need to be defined
# SelectedValuePath: no need to be defined
DisplayMemberPath="{Binding ElementName=Combobox2, StringFormat=@{0}, Path=SelectedValue}"
</ComboBox>
<ComboBox>
x:Name="Combobox2"
IsEnabled="{Binding CreateMode}"
ItemsSource="{Binding Source={StaticResource Languages}, XPath="LanguageInfo"}"
SelectedValue="{Binding Prop[LanguageName].value}"
SelectedValuePath="@LanguageName"
DisplayMemberPath="@LanguageName"
</ComboBox>
<ComboBox>
x:Name="Combobox3"
IsEnabled="{Binding CreateMode}"
ItemsSource="{Binding Source={StaticResource StandardTexts}, XPath="StandardTextInfo"}"
SelectedItem="{Binding SelectedItem, ElementName=ComboBox1, Mode=OneWay}"
# SelectedValue: no need to be defined
SelectedValuePath="@StandardTextNumber"
DisplayMemberPath="@StandardTextNumber"
</ComboBox>
</WPF:MainWindow>
最後に、期待される結果を得るための変更はそれほど多くありません。主なポイントは次のとおりです。
-understandの目的SelectedValueのとSelectedValuePathは属性
-バインディング構文StringFormat = @ {0}
質問2から4は今では無意味です。
ソリューションを提供してくれたBEIJINGRNL SOFTWARE SCIENCE&TECHCO.LTDのBAIXuesongに感謝します。
宜しくお願いします。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加