Skip to content

Commit

Permalink
完善 Card 属性
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Jun 11, 2024
1 parent 682d4d2 commit 9266e99
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ColumnDefinition/>
<ColumnDefinition Width="32"/>
</Grid.ColumnDefinitions>
<Slider x:Name="MainSlider" Grid.Column="0" Minimum="0.5" Maximum="1.5" TickFrequency="0.1" IsSnapToTickEnabled="True" Value="1" VerticalAlignment="Center"/>
<Slider x:Name="MainSlider" Grid.Column="0" Minimum="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SliderCard}, Mode=FindAncestor}, Path=Minimum}" Maximum="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SliderCard}, Mode=FindAncestor}, Path=Maximum}" TickFrequency="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SliderCard}, Mode=FindAncestor}, Path=TickFrequency}" IsSnapToTickEnabled="True" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SliderCard}, Mode=FindAncestor}, Path=Value}" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1" Text="{Binding Path=Value,Source={x:Reference Name=MainSlider}}" Foreground="{DynamicResource ForegroundColor}" VerticalAlignment="Center" Margin="12,0,0,0"/>
</Grid>
</ui:Flyout>
Expand Down
40 changes: 40 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,45 @@ public FontIconData Icon
// Using a DependencyProperty as the backing store for Icon. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(FontIconData), typeof(SliderCard), new PropertyMetadata(FluentSystemIcons.EmojiLaugh_20_Regular));

public double Value
{
get { return (double)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}

// Using a DependencyProperty as the backing store for Value. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(SliderCard), new PropertyMetadata((double)0));

public double Minimum
{
get { return (double)GetValue(MinimumProperty); }
set { SetValue(MinimumProperty, value); }
}

// Using a DependencyProperty as the backing store for Minimum. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register("Minimum", typeof(double), typeof(SliderCard), new PropertyMetadata((double)0));

public double Maximum
{
get { return (double)GetValue(MaximumProperty); }
set { SetValue(MaximumProperty, value); }
}

// Using a DependencyProperty as the backing store for Maximum. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register("Maximum", typeof(double), typeof(SliderCard), new PropertyMetadata((double)1));

public double TickFrequency
{
get { return (double)GetValue(TickFrequencyProperty); }
set { SetValue(TickFrequencyProperty, value); }
}

// Using a DependencyProperty as the backing store for TickFrequency. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TickFrequencyProperty =
DependencyProperty.Register("TickFrequency", typeof(double), typeof(SliderCard), new PropertyMetadata(0.1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TextBlock Foreground="{DynamicResource ForegroundColor}" FontSize="14" Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TextBoxCard}, Mode=FindAncestor}, Path=Header}"/>
<TextBlock Foreground="{DynamicResource ForegroundColor}" Opacity="0.75" FontSize="12" Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TextBoxCard}, Mode=FindAncestor}, Path=Tip}"/>
</ui:SimpleStackPanel>
<TextBox Grid.Column="2" VerticalAlignment="Center" Margin="12,0" Width="200" Height="32"/>
<TextBox Grid.Column="2" VerticalAlignment="Center" Margin="12,0" Width="200" Height="32" Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TextBoxCard},Mode=FindAncestor},Path=Text}"/>
</Grid>
</Border>
</UserControl>
10 changes: 10 additions & 0 deletions ZongziTEK_Blackboard_Sticker/Controls/Cards/TextBoxCard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,15 @@ public FontIconData Icon
// Using a DependencyProperty as the backing store for Icon. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(FontIconData), typeof(TextBoxCard), new PropertyMetadata(FluentSystemIcons.EmojiLaugh_20_Regular));

public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}

// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(TextBoxCard), new PropertyMetadata(""));
}
}

0 comments on commit 9266e99

Please sign in to comment.