我正在用MVVM模式编写WPF应用程序。介于两者之间(在ListBox中)我定义了ViewPort(短版本):
<ListBox>
<ListBox.Template>
<ControlTemplate>
<Border>
<Border.Background>
</Border.Background>
<ScrollViewer>
<Border>
<Border.Background>
<VisualBrush
TileMode="Tile"
Viewport="0,0,36,36"
ViewportUnits="Absolute"
Viewbox="0,0,20,20"
ViewboxUnits="Absolute">
</VisualBrush>
</Border.Background>
</Border>
</ScrollViewer>
</Border>
</ControlTemplate>
</ListBox.Template>
我喜欢在C#类中更改ViewPort的数量,但数字来自使用双变量的计算。那么问题是如何从double(4个数字)改为TileBrush?
我已经为TileBrush定义了get / set:
private System.Windows.Media.TileBrush _gridsquaresize;
public System.Windows.Media.TileBrush GridSquareSize
{
get { return _gridsquaresize; }
set
{
_gridsquaresize = value;
NotifyPropertyChanged("GridSquareSize");
}
}
答案 0 :(得分:1)