Click here to Skip to main content
15,347,523 members
Home / Discussions / WPF
   

WPF

 
QuestionUsing negative height margin values to properly vertically align a control Pin
Stephen Holdorf22-Jul-16 14:22
MemberStephen Holdorf22-Jul-16 14:22 
AnswerRe: Using negative height margin values to properly vertically align a control Pin
Stephen Holdorf23-Jul-16 4:50
MemberStephen Holdorf23-Jul-16 4:50 
GeneralRe: Using negative height margin values to properly vertically align a control Pin
Stephen Holdorf23-Jul-16 9:47
MemberStephen Holdorf23-Jul-16 9:47 
QuestionList Control Question Pin
Kevin Marois21-Jul-16 14:36
professionalKevin Marois21-Jul-16 14:36 
AnswerRe: List Control Question Pin
Gerry Schmitz22-Jul-16 11:18
mveGerry Schmitz22-Jul-16 11:18 
QuestionKeeping correct layout when browser is resized Pin
Stephen Holdorf17-Jul-16 3:37
MemberStephen Holdorf17-Jul-16 3:37 
AnswerRe: Keeping correct layout when browser is resized Pin
Gerry Schmitz18-Jul-16 6:19
mveGerry Schmitz18-Jul-16 6:19 
QuestionStyling a Drag and Drop Items behavior in a WPF ListView Pin
Kenneth Haugland13-Jul-16 5:43
mvaKenneth Haugland13-Jul-16 5:43 
So, I basically took the reordering from Josh Smith:
Drag and Drop Items in a WPF ListView[^]
All I wanted to do now was to draw a line where the new item was inserted, with an arrow. Like the old WinForms style behavior:
Manual reordering of items inside a ListView[^]

The line under was easy to achieve, all I had to was to alter the Style:
HTML
<Style x:Key="ItemContStyle" TargetType="ListViewItem">
          <Style.Resources>
              <LinearGradientBrush x:Key="MouseOverBrush" StartPoint="0.5, 0" EndPoint="0.5, 1">
                  <GradientStop Color="#22000000" Offset="0" />
                  <GradientStop Color="#44000000" Offset="0.4" />
                  <GradientStop Color="#55000000" Offset="0.6" />
                  <GradientStop Color="#33000000" Offset="0.9" />
                  <GradientStop Color="#22000000" Offset="1" />
              </LinearGradientBrush>

              <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" />
              <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
          </Style.Resources>

          <Setter Property="Padding" Value="0,4" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <!-- The default control template for ListViewItem has a Border
         which contains the item's content. -->
    <Setter Property="Border.BorderThickness" Value="0,0,0,0.5" />
          <Setter Property="Border.BorderBrush" Value="Transparent"/>
    <!-- These triggers react to changes in the attached properties set
         during a managed drag-drop operation. -->
    <Style.Triggers>
      <Trigger Property="jas:ListViewItemDragState.IsBeingDragged" Value="True">
        <Setter Property="FontWeight" Value="DemiBold" />
      </Trigger>
      <Trigger Property="jas:ListViewItemDragState.IsUnderDragCursor" Value="True">
                  <Setter Property="Border.BorderThickness" Value="0,0,0,0.5" />
                  <Setter Property="Border.BorderBrush" Value="Red"/>
              </Trigger>
    </Style.Triggers>
  </Style>

SO I looked at the ControlTemplate for the ListViewItems:
ListViewItem ControlTemplate Example[^]

But as soon as I started to add the ControlTemplate Design the correct behavior stopped:
HTML
<Style x:Key="ItemContStyle" TargetType="ListViewItem">
          <Style.Resources>
              <LinearGradientBrush x:Key="MouseOverBrush" StartPoint="0.5, 0" EndPoint="0.5, 1">
                  <GradientStop Color="#22000000" Offset="0" />
                  <GradientStop Color="#44000000" Offset="0.4" />
                  <GradientStop Color="#55000000" Offset="0.6" />
                  <GradientStop Color="#33000000" Offset="0.9" />
                  <GradientStop Color="#22000000" Offset="1" />
              </LinearGradientBrush>

              <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" />
              <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
          </Style.Resources>

          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="ListViewItem">
                          <Grid>
                          <Polygon
                              x:Name="poly_PART"
                              VerticalAlignment="Bottom"
                              HorizontalAlignment="Left"
                              Stroke="Red"
                              Fill="Red"
                              StrokeThickness="2"
                              Points="0,1 0,-1 1,0"
                              Margin="0,0,0,0"
                              Width="10"
                              Height="10"
                              Stretch="Fill"
                              />
                          <ContentPresenter
                              Content="{TemplateBinding Content}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                          </Grid>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>

          <Setter Property="Padding" Value="0,4" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <!-- The default control template for ListViewItem has a Border
         which contains the item's content. -->
    <Setter Property="Border.BorderThickness" Value="0,0,0,0.5" />
          <Setter Property="Border.BorderBrush" Value="Transparent"/>
    <!-- These triggers react to changes in the attached properties set
         during a managed drag-drop operation. -->
    <Style.Triggers>
      <Trigger Property="jas:ListViewItemDragState.IsBeingDragged" Value="True">
        <Setter Property="FontWeight" Value="DemiBold" />
      </Trigger>
      <Trigger Property="jas:ListViewItemDragState.IsUnderDragCursor" Value="True">
        <!--<Setter Property="Background" Value="{StaticResource MouseOverBrush}" />-->
                  <Setter Property="Border.BorderThickness" Value="0,0,0,0.5" />
                  <Setter Property="Border.BorderBrush" Value="Red"/>
              </Trigger>
    </Style.Triggers>
  </Style>


How do I fix this issue?
QuestionShort way defining a property with the NotifyPropertyChanged() call Pin
Mc_Topaz9-Jul-16 9:26
MemberMc_Topaz9-Jul-16 9:26 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mycroft Holmes9-Jul-16 11:35
professionalMycroft Holmes9-Jul-16 11:35 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mc_Topaz9-Jul-16 11:49
MemberMc_Topaz9-Jul-16 11:49 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Super Lloyd10-Jul-16 14:31
MemberSuper Lloyd10-Jul-16 14:31 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Pete O'Hanlon10-Jul-16 21:23
mvaPete O'Hanlon10-Jul-16 21:23 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Gerry Schmitz11-Jul-16 6:04
mveGerry Schmitz11-Jul-16 6:04 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Kenneth Haugland13-Jul-16 4:12
mvaKenneth Haugland13-Jul-16 4:12 
GeneralRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mycroft Holmes13-Jul-16 12:54
professionalMycroft Holmes13-Jul-16 12:54 
QuestionAdd column sorting to a WPF grid Pin
Stephen Holdorf7-Jul-16 7:11
MemberStephen Holdorf7-Jul-16 7:11 
SuggestionRe: Add column sorting to a WPF grid Pin
Matt T Heffron7-Jul-16 7:39
professionalMatt T Heffron7-Jul-16 7:39 
GeneralRe: Add column sorting to a WPF grid Pin
Stephen Holdorf7-Jul-16 8:11
MemberStephen Holdorf7-Jul-16 8:11 
AnswerRe: Add column sorting to a WPF grid Pin
Gerry Schmitz8-Jul-16 6:52
mveGerry Schmitz8-Jul-16 6:52 
QuestionSingle Instance WPF App - Pass Params From Second Instance To First Instance Pin
Kevin Marois30-Jun-16 8:46
professionalKevin Marois30-Jun-16 8:46 
QuestionWPF empty tabbed dashboard example code Pin
Stephen Holdorf28-Jun-16 12:07
MemberStephen Holdorf28-Jun-16 12:07 
AnswerRe: WPF empty tabbed dashboard example code Pin
Pete O'Hanlon28-Jun-16 20:53
mvaPete O'Hanlon28-Jun-16 20:53 
SuggestionRe: WPF empty tabbed dashboard example code Pin
Richard MacCutchan28-Jun-16 21:09
mveRichard MacCutchan28-Jun-16 21:09 
AnswerRe: WPF empty tabbed dashboard example code Pin
Gerry Schmitz1-Jul-16 5:47
mveGerry Schmitz1-Jul-16 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.