איך לקלוט פקד שנמצא בתוך controltempalte ב-wpf ?
-
יצרתי template עבור comboboxitem ב-wpf
כרגיל אני מצליח לקבל גישה אל אובייקטים מסוג זה דרך visualtreehelper או logicaltreehelperבמקרה שלי זה לא עובד לי. אשמח לקבל עזרה.
מצו"ב הקוד xaml אני מנזה לקבל גישה ל-treeview<ComboBox x:Name="HeadersCombo" Width="0" MaxDropDownHeight="300"> <ComboBox.Resources> <Style TargetType="ComboBoxItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <TextBox x:Name="ChapterTreeTexBox" Text="חפש כותרת" Height="20" MinWidth="50" MaxWidth="200" Grid.Row="0" Margin="2" Loaded="ChapterTreeTextBox_Loaded" KeyUp="ChapterTreeTexBox_KeyUp"/> <Separator Grid.Row="1" Margin="0" Padding="0"/> <TreeView x:Name="chapterTree" Grid.Row="2" BorderThickness="0" Padding="3" MaxHeight="260" MaxWidth="200" ItemsSource="{Binding IdItemsCollection}"> <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type chpaterTreeSource:IdItem}" ItemsSource="{Binding IdChildren}"> <TextBlock Text="{Binding ShortId}" Margin="0,3,5,3" Tag="{Binding BindsDirectlyToSource=True}" PreviewMouseDown="chapterTreeItem_PreviewMouseDown"/> </HierarchicalDataTemplate> <Style TargetType="TreeViewItem"> <Setter Property="IsExpanded" Value="True"/> </Style> </TreeView.Resources> </TreeView> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ComboBox.Resources> <ComboBoxItem/> </ComboBox>ועוד שאלה:
במקרה הזה ה-TreeView לא נטען עד שפותחים את ה-combobox האם יש איזה טריק שאוכל לעשות שייטען כאשר פותחים את היוזר פורם בו נמצא הcombobox?תודה מראש
-
יצרתי template עבור comboboxitem ב-wpf
כרגיל אני מצליח לקבל גישה אל אובייקטים מסוג זה דרך visualtreehelper או logicaltreehelperבמקרה שלי זה לא עובד לי. אשמח לקבל עזרה.
מצו"ב הקוד xaml אני מנזה לקבל גישה ל-treeview<ComboBox x:Name="HeadersCombo" Width="0" MaxDropDownHeight="300"> <ComboBox.Resources> <Style TargetType="ComboBoxItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <TextBox x:Name="ChapterTreeTexBox" Text="חפש כותרת" Height="20" MinWidth="50" MaxWidth="200" Grid.Row="0" Margin="2" Loaded="ChapterTreeTextBox_Loaded" KeyUp="ChapterTreeTexBox_KeyUp"/> <Separator Grid.Row="1" Margin="0" Padding="0"/> <TreeView x:Name="chapterTree" Grid.Row="2" BorderThickness="0" Padding="3" MaxHeight="260" MaxWidth="200" ItemsSource="{Binding IdItemsCollection}"> <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type chpaterTreeSource:IdItem}" ItemsSource="{Binding IdChildren}"> <TextBlock Text="{Binding ShortId}" Margin="0,3,5,3" Tag="{Binding BindsDirectlyToSource=True}" PreviewMouseDown="chapterTreeItem_PreviewMouseDown"/> </HierarchicalDataTemplate> <Style TargetType="TreeViewItem"> <Setter Property="IsExpanded" Value="True"/> </Style> </TreeView.Resources> </TreeView> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ComboBox.Resources> <ComboBoxItem/> </ComboBox>ועוד שאלה:
במקרה הזה ה-TreeView לא נטען עד שפותחים את ה-combobox האם יש איזה טריק שאוכל לעשות שייטען כאשר פותחים את היוזר פורם בו נמצא הcombobox?תודה מראש
@pcinfogmach כתב באיך לקלוט פקד שנמצא בתוך controltempalte ב-wpf ?:
ועוד שאלה:
במקרה הזה ה-TreeView לא נטען עד שפותחים את ה-combobox האם יש איזה טריק שאוכל לעשות שייטען כאשר פותחים את היוזר פורם בו נמצא הcombobox?לבינתיים עשיתי שה-combobox יהיה פתוח כהuserform נפתח ואז עשיתי שטעינת ה-tree דהיינו ה-load יסגור את ה-comboview עם תנאי bool שזה יקרה רק בטעינה הראשונה - המשתמש לא רואה כלום. דא עקא שזה די מאט את טעינת הuserform.
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות