如何代碼WPF轉換器在WPF顯示四位狀態圖標,在我的項目,我打算基於某些條件 1)紅點圖標,顯示以下四種狀態 - 未保存的數據 2)綠點圖標 - 保存成功 3)白點圖標或無圖標 - 窗口已成功初始化,並且沒有未保存的數據。 4)錯誤圖標 - 保存數據時發生錯誤。字符串到圖像WPF轉換器
任何幫助將不勝感激,在此先感謝。
如何代碼WPF轉換器在WPF顯示四位狀態圖標,在我的項目,我打算基於某些條件 1)紅點圖標,顯示以下四種狀態 - 未保存的數據 2)綠點圖標 - 保存成功 3)白點圖標或無圖標 - 窗口已成功初始化,並且沒有未保存的數據。 4)錯誤圖標 - 保存數據時發生錯誤。字符串到圖像WPF轉換器
任何幫助將不勝感激,在此先感謝。
如果你想改變窗口圖標simpliest方法是創建所有圖標並將其保存爲資源,然後以改變它:
Uri iconUri = new Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);
如果你想只是爲了顯示你的表格你畫上點一個圓並改變其顏色與yourCircle.Fill(newColor)
這個例子是從msdn:
要繪製圓,指定橢圓 瓦特軟管寬度和高度值是 相等。
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace SDKSample
{
public partial class SetBackgroundColorOfShapeExample : Page
{
public SetBackgroundColorOfShapeExample()
{
// Create a StackPanel to contain the shape.
StackPanel myStackPanel = new StackPanel();
// Create a red Ellipse.
Ellipse myEllipse = new Ellipse();
// Create a SolidColorBrush with a red color to fill the
// Ellipse with.
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
// Describes the brush's color using RGB values.
// Each value has a range of 0-255.
mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
myEllipse.Fill = mySolidColorBrush;
myEllipse.StrokeThickness = 2;
myEllipse.Stroke = Brushes.Black;
// Set the width and height of the Ellipse.
myEllipse.Width = 200;
myEllipse.Height = 100;
// Add the Ellipse to the StackPanel.
myStackPanel.Children.Add(myEllipse);
this.Content = myStackPanel;
}
}
}
非常感謝,建議我會畫圈並改變它的顏色。 – 2009-09-01 19:50:50
你的意思是如何更改的圖標顯示在窗口標題或只是爲了顯示點? – 2009-09-01 11:49:28