内部にグリッドコントロールがあるユーザーコントロールがあります
<UserControl x:Class="MyGrid">
<Telerik:RadGridView EnableRowVirtualization="false">
</Telerik:RadGridView/>
</UserControl>
DependencyPropertyを使用してusercontrol内のコントロールのEnableRowVirtualizationプロパティを公開して、誰かがMyGrid usercontrolを使用したときに、ユーザーが次のようなことを行うようにするにはどうすればよいですか?
<grids:MyGrid EnableRowVirtualization="false"> </grids:MyGrid>
更新:今、これは私が思いついたものです
public partial class MyGrid //myGrid userControl
{
public bool EnableRowVirtualization
{
get { return (bool)GetValue(EnableRowVirtualizationProperty); }
set { SetValue(EnableRowVirtualizationProperty, value); }
}
// Using a DependencyProperty as the backing store for EnableRowVirtualization. This enables animation, styling, binding, etc...
public static readonly DependencyProperty EnableRowVirtualizationProperty =
DependencyProperty.Register("EnableRowVirtualization", typeof(bool), typeof(MaxGridView), new UIPropertyMetadata(false, OnEnableRowVirtualizationPropertyChanged)
);
private static void OnEnableRowVirtualizationPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
{
var grid = (RadGridView)depObj;
if (grid != null)
{
grid.EnableRowVirtualization = (bool)e.NewValue;
}
}