0
我想表現出以下行爲在我的StackPanel刷:顯示刷子的一部分在一個StackPanel
- 刷機的圖像製作240x120
- 面板爲240x60
我想要顯示像rect(0,30,240,60)這樣的畫筆的一部分(使面板上的圖像向下移動一下) 用viewport和Viewbox試了一下沒有結果(空面板)
這是我的代碼:
for (int i = 0; i < listExplorationData.Count; i++)
{
StackPanel panelLoop = new StackPanel();
panelLoop.Name = "panel_" + i.ToString();
panelLoop.Width = 240;
panelLoop.Height = 60;
panelLoop.Margin = new Thickness(0, 60 * i, 0, 0);
BitmapImage image = new BitmapImage(
new Uri("pack://application:,,,/GW2-MyWorldExploration;component/Images/" +
listExplorationData[i].mapname_en.Replace(" ", "_") +
"_loading_screen.jpg"));
ImageBrush brush = new ImageBrush();
brush.ImageSource = image;
brush.Stretch = Stretch.None;
brush.Viewport = new Rect(0, 30, 240, 60);
panelLoop.Background = brush;
mainStackPanel.Children.Add(panelLoop);
}
你不必在前面加上標籤的問題。請閱讀http://meta.stackexchange.com/q/19190瞭解更多信息。 – Patrick