WPF कैसे बनाने के लिए विस्तारक कदम सामग्री
हाय मैं अपने WinForms आवेदन में ElementHost को WPF नियंत्रण जोड़ना चाहते हैं। मेरे नियंत्रण का व्यवहार चित्र पर चित्रित किया गया है। मैं किसी भी विस्तारक का विस्तार करना चाहता हूं कि मेरा वृक्षदृश्य नियंत्रण छोटे आकार में बदल जाए। और शुरुआत में मैं चाहता हूं कि मेरे विस्तारक ढह जाएंगे।
ऐसामैं कोशिश कर रहा था sth:
<UserControl x:Class="LeftPane"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
<Grid VerticalAlignment="Stretch" Margin="3,3,3,3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TreeView Grid.Row="0" Name="treeView1" VerticalAlignment="Stretch" >
</TreeView>
<StackPanel Grid.Row="1" Name="StackPanel1" VerticalAlignment="Bottom">
<ListBox SelectedIndex="1">
<ListBoxItem VerticalAlignment="Stretch">
<Expander Grid.Row="1" ExpandDirection="Down" Header="expander1" VerticalAlignment="Stretch" Name="expander1" IsExpanded="False">
<ListBox>
<ListBoxItem Content="Unit 1"/>
<ListBoxItem Content="Unit 2"/>
</ListBox>
</Expander>
</ListBoxItem>
<ListBoxItem VerticalAlignment="Stretch">
<Expander Grid.Row="2" ExpandDirection="Down" Header="expander2" VerticalAlignment="Stretch" Name="expander2" IsExpanded="False">
<ListBox>
<ListBoxItem Content="Unit 1"/>
<ListBoxItem Content="Unit 2"/>
</ListBox>
</Expander>
</ListBoxItem>
</ListBox>
</StackPanel>
</Grid>
और:
public void AddControl(ElementHost host)
{
this.parentHost = host;
host.Child = this;
this.Height = host.Size.Height;
treeView1.MaxHeight = this.Height - 60;
}
लेकिन इसे सही ढंग से काम नहीं करता। जब मैं अपनी WinForms विंडो का आकार बदलता हूं तो मैं इस नियंत्रण का आकार बदलना चाहता हूं।
किसी को भी मेरी मदद कर सकते स्थापित करने के लिए कैसे aligment आदि
यह एक विस्तारक दूसरे पर दिखाई देता है। और जब मैं पैरेंट WinForms विंडो का आकार बदलता हूं तो नियंत्रण अधिक स्केल नहीं होता है। – santBart
@ सैंटबार्ट मान लीजिए शेरिडन का अर्थ है ग्रिड। पंक्ति = "2" दूसरे विस्तारक – Alex
धन्यवाद @voo। क्षमा करें, मेरी गलती ... मैंने अभी अपना कोड अपडेट कर लिया है। – Sheridan