В моем MainWindow.xaml
это представление таблицы данных и ix: назовите его «MyList».
System.InvalidOperationException: «MyList» имя не может быть найдено в области имен «System».Windows.Controls.Button '.'
Скажите мне, как я называю свою сетку данных, чтобы иметь возможность доступа к ней на других страницах или как я ссылаюсь или использую MainWindow.xaml на других страницах / usercontrols
Редактировать:
это моя сетка данных с именем MyList и она находится в MainWindow: `` `
VerticalGridLinesBrush="White"
BorderThickness="1"
CanUserResizeColumns="False"
CanUserResizeRows="False"
ClipboardCopyMode="IncludeHeader"
AllowDrop="True"
SelectionMode="Extended"
Foreground="#FF434343"
AlternatingRowBackground="#FFEFF0DD"
CanUserAddRows="False" Background="White" RenderTransformOrigin="0.5,0.5" BorderBrush="{x:Null}"
>
<DataGrid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DataGrid.RenderTransform>
<DataGrid.Columns>
<DataGridTextColumn Header="ردیف" Width="75" FontSize="16" Binding="{Binding Path=id}" IsReadOnly="True" ></DataGridTextColumn>
<DataGridTextColumn Header="نام" Width="200" FontSize="16" Binding="{Binding Path=name}" IsReadOnly="True"></DataGridTextColumn>
<DataGridTextColumn Header="تعداد" Width="auto" FontSize="16" Binding="{Binding Path=tedad}" IsReadOnly="True"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>```
теперь вот app.xaml и мне нужно сослаться на mainwindow, чтобыздесь, но я не знаю, как добавить его в xaml: `` `
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<!--#region User Control Add-->
<!--#region Anime Open Add-->
<Storyboard x:Key="anmOpenAdd">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="AddPage">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-350"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-350"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-320"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--#endregion-->
<!--#region Anime Close Add-->
<Storyboard x:Key="anmCloseAdd">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="AddPage">
<EasingDoubleKeyFrame KeyTime="0" Value="-320"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-350"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="20"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--#endregion-->
<!--#endregion-->
<!--#region Edit User Control-->
<!--#region Edit Open Up-->
<Storyboard x:Key="anmEditOpen">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="EditPage">
<EasingDoubleKeyFrame KeyTime="0" Value="-320"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="anmMyListEditOpen">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="MyList">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="320"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--#endregion-->
<!--#region Edit Close Up-->
<Storyboard x:Key="anmEditClose">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="EditPage">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-340"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="anmMyListEditClose">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="{Binding ElementName=MyList}">
<EasingDoubleKeyFrame KeyTime="0" Value="320"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--#endregion-->
<!--#endregion-->
<!--#region Resource Disctionary-->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Grey.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
<!--#endregion-->
</ResourceDictionary>