MahApps.Metro ProgressRingコントロールのデフォルトは最小サイズ60x60です。MahApps.MetroでProgressRingを小さくする
"IsLarge"と呼ばれるProgressRingのプロパティがありますが、 "False"に設定されていても、ProgressRingを60x60より小さくすることはできません。
また、高さと幅のプロパティを意識的に変更しても、これには影響しません。
ProgressRingの実際のC#コードとしてGitHUbを見ると、楕円の直径などに影響を及ぼすいくつかのプロパティがあるように見えますが、これらのプロパティはプライベートプロパティであり、外部呼び出しから設定することはできません。
これをもっと小さくするにはどうすればよいですか? 20x20または30x30と言ってもよろしいですか?
以下のコードでは、IsLarge = Falseと指定し、サイズを30x30に設定しますが、デフォルトでは60x60に設定されています。 MainWindow.xaml
<Grid>
<Controls:ProgressRing x:Name="PRing" IsLarge="False" MinHeight="15" MinWidth="15" Height="15" Width="15"></Controls:ProgressRing>
</Grid>
EDIT:以下
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Orange.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Controls:ProgressRing IsActive="True" IsLarge="False" Height="30" Width="30"></Controls:ProgressRing>
</Grid>
</Window>
namespace MahApps.Metro.Controls
{
[TemplateVisualState(Name = "Large", GroupName = "SizeStates")]
[TemplateVisualState(Name = "Small", GroupName = "SizeStates")]
[TemplateVisualState(Name = "Inactive", GroupName = "ActiveStates")]
[TemplateVisualState(Name = "Active", GroupName = "ActiveStates")]
public class ProgressRing : Control
private void SetMaxSideLength(double width)
{
MaxSideLength = width <= 60 ? 60.0 : width;
}
private void SetEllipseDiameter(double width)
{
if (width <= 60)
{
EllipseDiameter = 6.0;
}
else
{
EllipseDiameter = width * 0.1 + 6;
}
}
private void UpdateLargeState()
{
Action action;
if (IsLarge)
action =() => VisualStateManager.GoToState(this, "Large", true);
else
action =() => VisualStateManager.GoToState(this, "Small", true);
if (_deferredActions != null)
_deferredActions.Add(action);
else
action();
}
EDITで見つかった "ProgressRing.cs" ファイルからのコードの抜粋ですMainWindow.xaml.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
PRing.EllipseDiameter = 5;
}
}
MinHeightとMinWidthを設定しても動作していたようですが、現在の制限は30x30です!私が試してみると、それより小さいものは同じままで、楕円の円の直径のために必要な最小の高さ/幅があるので、私は推測していますか? ;-) –
さらに、高さと幅、そしてminheightとminwidthを20x20に設定しようとしましたが、それでも30x30のままでした。 –
@J P:楕円の幅/高さを小さくする必要がありますか?または、幅/高さを30x30未満に設定しますか?少ない場合は、どれくらい? –