简体   繁体   中英

Viewbox, Viewportcontroller and scrollviewer

I am trying to create a game where I have a scrollable map, by map I mean a gameMap, inside a scrollviewer. But I have problems with the smoothness, when manipulating elements inside the scrollviewer.

I therefore stumbled upon the Viewbox and viewportcontrol. I have tried to read about these but not found anything that really describes, not even on msdn.

I therefore wanted to know if anyone has experience with the other controls, and can tell me if they would be smart to use for a map based game, and maybe a link for some description regarding the usage of these?

I am Using Bing Map Task.It is So smooth.

This is Xaml Code.

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>

    </Grid.RowDefinitions>
    <StackPanel x:Name="stkhead"    Grid.Row="0">
        <TextBlock Text="Bing Map and Location Service" HorizontalAlignment="Center"></TextBlock>
    </StackPanel>
    <StackPanel x:Name="stkInfo" Grid.Row="1">
        <TextBlock x:Name="tblcurpos" Text="Current Position :-" Width="150" HorizontalAlignment="Left"/>
        <TextBlock x:Name="tblcurpos1" Text="" Width="120" HorizontalAlignment="Center" Margin="0,-25,0,0"/>

    </StackPanel>
    <StackPanel x:Name="stkmap" Grid.Row="2">

    </StackPanel>
    <StackPanel x:Name="stksearch" Grid.Row="3">
        <TextBlock x:Name="tblsearch" Text="Search"></TextBlock>
        <TextBox x:Name="txtsearch" Width="380" Margin="0,-38,0,0"  Text=""></TextBox>
        <Button Name="btnsearch" Content="Search" Height="75" Width="195" Tap="btnsearch_Tap_1"></Button>
    </StackPanel>

</Grid>

Here is the C# Code.

public MainPage()
{
        InitializeComponent();
        FindMe();
}
private void Bingtask()
{
    BingMapsTask bingMap = new BingMapsTask();
    bingMap.SearchTerm = txtsearch.Text; 
    bingMap.ZoomLevel = 10;
    bingMap.Show();
}
    private void FindMe()
    {
        tblcurpos1.Text = "Not Found";
    }

   private void btnsearch_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
   {
        Bingtask();
   }

What I have found is there is a problem with scrollviewer and viewbox to work together. Or at least I have had big problems. Therefore Viewportcontrol is the way to go, because it has the viewport and scrollviewer incorporated.

Finally it is the viewportcontroller that is the basis of the longlistselector, which would imply the viewportcontroller is useful, you just need to get it to work :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM