Share usage examples of PART_Editor

零下一度
Release: 2017-06-23 15:56:41
Original
1706 people have browsed it

1. Foreword

##                   In daily life In interface development, we mostly use the MVVM model for development. Normally, the ItemsSource of a PropertyGridControl or DataGrid is set up,

and then each column is bound to a field in an ItemsSource and then it can run .

But there is another situation:

## Assume an interface Temp.xaml, Its ViewModel is TempViewModel.cs;

There is a PropertyGridControl ItemsSource bound to ObservableCollection

JloprtyGridControl, a PropertyDefinition in the TEMPLATE, which is bound to be rewritten. #                                                                                              It may also It may include several fields in the Model, or even Some other information in the TempViewModel. How should I operate at this time?

2. Example

Temp.xaml:

 <services:DockablePane.Resources>
        <ResourceDictionary>
             <DataTemplate x:Key="EditTemplate">
                <special:SpEdit x:Name="PART_Editor"/>  //这里是关键!!!!!!!!!!!!!!!
            </DataTemplate>
        </ResourceDictionary>
 </services:DockablePane.Resources>



<dxprg:PropertyGridControl 
                Margin="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"SelectedObjects="{Binding Infos}" ShowProperties="WithPropertyDefinitions"ShowDescriptionIn="ToolTipAndPanel" ShowCategories="True" ExpandCategoriesWhenSelectedObjectChanged="True"ShowMenuButtonInRows="False" ShowToolPanel="False" ShowSearchBox="False" SortMode="Definitions">

 <dxprg:PropertyGridControl.PropertyDefinitions>
                        <!--通用-->
                        <dxprg:PropertyDefinition IsReadOnly="True" Path="Code"/>
                        <dxprg:PropertyDefinition IsReadOnly="True" Path="AProperty"/>
                        <dxprg:PropertyDefinition Path="BProperty"/>
                        <dxprg:PropertyDefinition Path="CProperty"/>
                        <dxprg:PropertyDefinition Path="DProperty"/>
                        <dxprg:PropertyDefinition Path="EProperty"  ContentTemplate="{StaticResource EditTemplate}"/>
 </dxprg:PropertyGridControl.PropertyDefinitions>
</dxprg:PropertyGridControl>
Copy after login

Here, the name of the form in the DataTemplate we override is :

PART_Editor

This name is very important and cannot be changed. In this way we can call all the information of TempViewModel

in the form

SpEdit, because at this time TempViewModel

On a

attribute that has been assigned to the DataContext of SpEdit, the possible situation is as follows: SpEdit.xaml.cs:

var source = this.DataContext as RowData;if (source != null)
     _sourceData = (source.Definition.DataContext) as VM;
Copy after login
In this way, we pass the ViewModel of Temp.xaml to SpEdit's_sourceData.

##3. Summary

# #      This article mainly describes how to obtain the ViewModel information in the source UI in the rewrite interface. PART_Editor is a very practical hidden method.

The above is the detailed content of Share usage examples of PART_Editor. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!