This is a migrated thread and some comments may be shown as answers.

QueryableCollectionView & Blend - design time data

2 Answers 31 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 30 Apr 2011, 11:54 PM
Greetings Telerik Team!

Running an SL4 app with Telerik Q1 2011 toolkit with Mvvm Light

I had been using a dataform/radGridView together with an ObservableCollection which, among other things, was giving me design time data in blend. I wanted to include a datapager, and switched to a QueryableCollectionView bound to the itemssource/source of my dataform/radgridview/raddatapager. Upon doing so, I could no longer see my design time data in blend.

I'm using a service interface which implements a base class that uses the DesignerProperties.IsInDesignTool property to determine whether I should return a design time service or my run time web service.

Is the QCV not blendable?

Here's my ViewModel

public void LoadAccounts()
{
    Accounts = null;
    AccountService.GetAccounts(App.CurrentUser.ToString(), GetAccountsCallback);
}
private void GetAccountsCallback(ObservableCollection<TSMVVM.Model.Accounts> accounts)
{
    if (accounts != null)
        {
             if (accounts.Count > 0) {
             Accounts = new QueryableCollectionView(accounts)
             SelectedAccount = null;
         }
}
private QueryableCollectionView _accounts;
public QueryableCollectionView Accounts
        {
            get { return _accounts; }
            set
            {
                _accounts = value;
                RaisePropertyChanged("Accounts");
            }
        }

View:
<toolkit:DataForm x:Name="dataForm"
    Header="Account Definition"
    Width="{Binding Width, ElementName=GV1}"
    ItemsSource="{Binding Accounts}"
    CurrentItem="{Binding SelectedAccount}"
    AutoEdit="False"
    AutoGenerateFields="False"
    AutoCommit="False"
    Margin="0,0,0,10" >
</toolkit:DataForm>
<telerik:RadGridView ItemsSource="{Binding Accounts}"
    x:Name="GV1"
    ShowGroupPanel="False"
    DataLoadMode="Asynchronous"
    HorizontalAlignment="Left"
    HeaderRowStyle="{StaticResource CSAgvHeaderRowStyle}"
    SelectedItem="{Binding SelectedAccount, Mode=TwoWay}"
    AutoGenerateColumns="False"
    IsReadOnly="True">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn HeaderCellStyle="{StaticResource CSAgvHeaderCellStyle}" DataMemberBinding="{Binding AccountNumber}"/>
        <telerik:GridViewDataColumn HeaderCellStyle="{StaticResource CSAgvHeaderCellStyle}" DataMemberBinding="{Binding AccountDescription}" Width="*"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataPager Grid.Row="1" Source="{Binding Accounts}" PageSize="10"/>

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 May 2011, 07:43 AM
Hello,

 As far as I know you will not have any problems to use QueryableCollectionView in both Blend and Visual Studio design-time however you need to bind in some design-time aware way - not in code. For example using StaticResource.

I've attached small example application and two screenshots from Blend and Visual Studio. 

All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Scott
Top achievements
Rank 1
answered on 02 May 2011, 05:42 PM
I think I have to disagree with your statement that you can't use code. If you can't use code, the DesignerProperties API wouldn't exist. I use this code to return design time data:

public static ServiceProviderBase Instance
{
    get { return _instance ?? CreateInstance();
}
static ServiceProviderBase CreateInstance()
{
    return _instance = DesignerProperties.IsInDesignTool ?
                (ServiceProviderBase)new DesignServices.DesignServiceProvider() : new Services.ServiceProvider();
}

So when I'm loading my Accounts view, it hits this interface. IsInDesignTool evaluates to true, and it returns an instance of my designserviceprovider, which goes out to get data generated in my DesignAccounts, here:

public DesignAccounts()
{
    for (int i = 0; i < 20; i++)
    {
        Add(CreateDesignAccount(i));
    }
}
 
private TSMVVM.Model.Accounts CreateDesignAccount(int i)
{
    var account = new TSMVVM.Model.Accounts()
    {
        AccountDescription = "Account" + i,
         AccountNumber = (i >= 10) ? "000.00" + i : "000.000" + i,
    };
    return account;
}

As I said, this works with an ObservableCollection<Accounts>, but not a QueryableCollectionView(Accounts).
Tags
General Discussions
Asked by
Scott
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Scott
Top achievements
Rank 1
Share this question
or