דילוג לתוכן
  • דף הבית
  • קטגוריות
  • פוסטים אחרונים
  • משתמשים
  • חיפוש
  • חוקי הפורום
כיווץ
תחומים

תחומים - פורום חרדי מקצועי

💡 רוצה לזכור קריאת שמע בזמן? לחץ כאן!
  1. דף הבית
  2. תכנות
  3. ארכיון code613m
  4. command WPF

command WPF

מתוזמן נעוץ נעול הועבר ארכיון code613m
6 פוסטים 3 כותבים 410 צפיות
  • מהישן לחדש
  • מהחדש לישן
  • הכי הרבה הצבעות
התחברו כדי לפרסם תגובה
נושא זה נמחק. רק משתמשים עם הרשאות מתאימות יוכלו לצפות בו.
  • ש מנותק
    ש מנותק
    שמואל
    כתב ב נערך לאחרונה על ידי
    #1

    knhavut hsug?
    האם שימוש בקומנדים ב WPF זה רק כאשר משתמשים בארכיטקטורת MVVM?

    פורסם במקור בפורום CODE613 ב09/03/2014 20:18 (+02:00)

    תגובה 1 תגובה אחרונה
    0
    • dovidD מנותק
      dovidD מנותק
      dovid ניהול
      כתב ב נערך לאחרונה על ידי
      #2

      זה אכן הולך חזק עם MVVM אבל אתה יכול ליישם את זה בלי להיות עקבי ולהיות MVVMניק :).
      זה מאוד מתאים למקרים של פקודה מקושרת למופע כל שהוא.

      פורסם במקור בפורום CODE613 ב09/03/2014 21:22 (+02:00)

      מנטור אישי למתכנתים (ולא רק) – להתקדם לשלב הבא!

      בכל נושא אפשר ליצור קשר dovid@tchumim.com

      תגובה 1 תגובה אחרונה
      1
      • רחמיםר מנותק
        רחמיםר מנותק
        רחמים מורחק
        כתב ב נערך לאחרונה על ידי
        #3

        קומנד יכול להיות מאוד שימושי עבור עריכת טקסט בתיבת טקסט עשיר למשל כך:

        <StackPanel Orientation="Horizontal" Height="24" Background="{Binding ElementName=FsRichTextBoxControl, Path=ToolbarBackground}" >
        
                    <!-- Font drop-down code from http://www.bennedik.de/2007/10/wpf-fast-font-drop-down-list.html -->
        
                    <!-- Font family combo box  -->
                    <ComboBox x:Name="FontFamilyCombo" Height="23" Width="100" 
                              Margin="5,2,0,2" IsEditable="True" 
                              SelectionChanged="OnFontFamilyComboSelectionChanged">
                        <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel Width="250" />
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding}" FontFamily="{Binding}" FontSize="15" Height="20"/>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
        
                    <!-- Font size combo box -->
                    <ComboBox x:Name="FontSizeCombo" Height="23" Width="40" Margin="5,2,5,2" IsEditable="True" SelectionChanged="OnFontSizeComboSelectionChanged" />
                    
                    <Button Command="ApplicationCommands.Cut" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Cut" Template="{StaticResource FlatButtonControlTemplate}" Margin="0,1,0,1">
                        <Image Source="Images\editcut.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button Command="ApplicationCommands.Copy" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Copy" Template="{StaticResource FlatButtonControlTemplate}" Margin="0,1,0,1">
                        <Image Source="Images\editcopy.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button Command="ApplicationCommands.Paste" 
                            CommandTarget="{Binding ElementName=TextBox}" 
                            ToolTip="Paste" Template="{StaticResource FlatButtonControlTemplate}" Margin="0,1,0,1">
                        <Image Source="Images\editpaste.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button Command="ApplicationCommands.Undo" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Undo" Template="{StaticResource FlatButtonControlTemplate}"  Margin="0,1,0,1">
                        <Image Source="Images\editundo.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button Command="ApplicationCommands.Redo" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Redo" Template="{StaticResource FlatButtonControlTemplate}"  Margin="0,1,0,1">
                        <Image Source="Images\editredo.png" Stretch="None"  SnapsToDevicePixels="True" />
                    </Button>
        
                    <Image Source="Images\separator.png" Stretch="None" SnapsToDevicePixels="True" />
        
                    <ToggleButton x:Name="BoldButton" Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Bold" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1">
                        <Image Source="Images\fontbold.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                    <ToggleButton x:Name="ItalicButton" Command="EditingCommands.ToggleItalic" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Italic" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1">
                        <Image Source="Images\fontitalic.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                    <ToggleButton x:Name="UnderlineButton" Command="EditingCommands.ToggleUnderline" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Underline" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1">
                        <Image Source="Images\fontunderline.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
                    <Image Source="Images\separator.png" Stretch="None" SnapsToDevicePixels="True" />
        
                    <Button ToolTip="Format as normal (non-code) text" Template="{StaticResource FlatButtonControlTemplate}" Margin="0,1,0,1" Visibility="{Binding Path=CodeControlsVisibility, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Click="OnNormalTextClick">
                        <Image Source="Images\normaltext.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button ToolTip="Format as code block" Template="{StaticResource FlatButtonControlTemplate}" Margin="0,1,0,1" Visibility="{Binding Path=CodeControlsVisibility, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Click="OnCodeBlockClick">
                        <Image Source="Images\codeblock.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button ToolTip="Format as inline code" Template="{StaticResource FlatButtonControlTemplate}" Margin="0,1,0,1" Visibility="{Binding Path=CodeControlsVisibility, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Click="OnInlineCodeClick">
                        <Image Source="Images\codeinline.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Image Source="Images\separator.png" Stretch="None" SnapsToDevicePixels="True" Visibility="{Binding Path=CodeControlsVisibility, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
        
                    <ToggleButton x:Name="LeftButton" Command="EditingCommands.AlignLeft" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Align Left" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1" Click="OnAlignmentButtonClick">
                        <Image Source="Images\alignleft.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                    <ToggleButton x:Name="CenterButton" Command="EditingCommands.AlignCenter" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Align Center" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1" Click="OnAlignmentButtonClick">
                        <Image Source="Images\aligncenter.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                    <ToggleButton x:Name="RightButton" Command="EditingCommands.AlignRight" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Align Right" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1" Click="OnAlignmentButtonClick">
                        <Image Source="Images\alignright.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                    <ToggleButton x:Name="JustifyButton" Command="EditingCommands.AlignJustify" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Align Justify" Template="{StaticResource FlatToggleButtonControlTemplate}" Margin="0,1,0,1" Click="OnAlignmentButtonClick">
                        <Image Source="Images\alignjustify.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
                    <Image Source="Images\separator.png" Stretch="None" SnapsToDevicePixels="True" />
        
                        <ToggleButton x:Name="BulletsButton" Command="EditingCommands.ToggleBullets" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Bullets" Template="{StaticResource FlatToggleButtonControlTemplate}"  Margin="0,1,0,1" Click="OnListButtonClick">
                        <Image Source="Images\listbullets.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                        <ToggleButton x:Name="NumberingButton" Command="EditingCommands.ToggleNumbering" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Numbering" Template="{StaticResource FlatToggleButtonControlTemplate}"  Margin="0,1,0,1" Click="OnListButtonClick">
                        <Image Source="Images\listnumbers.png" Stretch="None" SnapsToDevicePixels="True" />
                    </ToggleButton>
        
                    <Image Source="Images\separator.png" Stretch="None" />
        
                    <Button Command="EditingCommands.IncreaseIndentation" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Increase Indentation" Template="{StaticResource FlatButtonControlTemplate}"  Margin="0,1,0,1">
                        <Image Source="Images\indentincrease.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                    <Button Command="EditingCommands.DecreaseIndentation" CommandTarget="{Binding ElementName=TextBox}" ToolTip="Decrease Indentation" Template="{StaticResource FlatButtonControlTemplate}"  Margin="0,1,0,1">
                        <Image Source="Images\indentdecrease.png" Stretch="None" SnapsToDevicePixels="True" />
                    </Button>
        
                </StackPanel>
        

        ראה שיש כאן שתי קבוצות של פקודות EditingCommands ו ApplicationCommands

        פורסם במקור בפורום CODE613 ב09/03/2014 22:36 (+02:00)

        תגובה 1 תגובה אחרונה
        1
        • ש מנותק
          ש מנותק
          שמואל
          כתב ב נערך לאחרונה על ידי
          #4

          אם הבנתי נכון EditingCommands זה קומנד שאתה יוצר לבד?!
          אם כן לא הבנתי מה עשית שם
          תמיד חשבתי שהדרך יותר מורכבת עם relaycommand וכו'
          אולי תוכל יותר להסביר?

          פורסם במקור בפורום CODE613 ב10/03/2014 15:38 (+02:00)

          תגובה 1 תגובה אחרונה
          0
          • רחמיםר מנותק
            רחמיםר מנותק
            רחמים מורחק
            כתב ב נערך לאחרונה על ידי
            #5

            זו בדיוק הנקודה שתי הקבוצות של פקודות EditingCommands ו ApplicationCommands אתה לא צריך ליצור כלל אתה יכול להדביק את הקוד דלעיל אצלך בתוכנית בכל טופס וזה יעבוד !

            פורסם במקור בפורום CODE613 ב10/03/2014 15:43 (+02:00)

            תגובה 1 תגובה אחרונה
            0
            • ש מנותק
              ש מנותק
              שמואל
              כתב ב נערך לאחרונה על ידי
              #6

              מה שאני התכוונתי זה ל command שעורכים אותו לבד למשל שיעשה פעולת שמירה בדטהבייס

              פורסם במקור בפורום CODE613 ב10/03/2014 16:07 (+02:00)

              תגובה 1 תגובה אחרונה
              0

              בא תתחבר לדף היומי!
              • התחברות

              • אין לך חשבון עדיין? הרשמה

              • התחברו או הירשמו כדי לחפש.
              • פוסט ראשון
                פוסט אחרון
              0
              • דף הבית
              • קטגוריות
              • פוסטים אחרונים
              • משתמשים
              • חיפוש
              • חוקי הפורום